Welcome Guest Search | Active Topics | Sign In | Register

HtmlToPDf ConvertUrl sometimes Javascript not rendering Options
Fractus
Posted: Tuesday, May 26, 2015 4:12:11 PM

Rank: Member
Groups: Member

Joined: 9/3/2013
Posts: 16
Hi,

I have a random issue, sometime a javascript (jquery) Grid doesnt get render in the PDF. It's a Telerik KendoGrid.

To PDF form the same url.
https://www.dropbox.com/s/uw07gg16g6xwiy9/Documents.zip?dl=0

This is my code:
HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4;
HtmlToPdf.Options.PreserveHighResImages = false;
HtmlToPdf.Options.JpegQualityLevel = 90;
HtmlToPdf.Options.GeneratePageImages = true;
HtmlToPdf.Options.MinLoadWaitTime = 10000;
HtmlToPdf.Options.PageSize = new System.Drawing.SizeF(PdfPageSizes.A4.Height, PdfPageSizes.A4.Width);
HtmlToPdf.Options.VisibleElementIds = "panelanalisis";
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.ShrinkToFit;
HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 0.25f, 10.75f, 8.0f);
System.IO.TextWriter writeFile = new StreamWriter("c:\\temp\\textwriter" + DateTime.Now.ToString("mmssfff") + ".txt", true);
HtmlToPdf.DebugConsole = writeFile;
HtmlToPdf.Options.BaseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
HtmlToPdfResult oResultHtmlToPdf = HtmlToPdf.ConvertUrl(SPContext.Current.Site.Url + "/" + SPContext.Current.File.Url + "?" + this.Page.Request.QueryString.ToString(), pdfStream);
pdfStream.Position = 0;
byte[] contents = ReadFully(pdfStream);

The debugconsole is empty, no JS errors and my version is 5.0.84.2

Fractus - Developer & Consulting
eo_support
Posted: Tuesday, May 26, 2015 4:49:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

We can't tell much just by this. You might want to run a package monitor to see if the request has indeed been sent to the server and the server has responded properly when this happens. That might be able to reveal something.

Thanks!
Fractus
Posted: Tuesday, May 26, 2015 4:51:24 PM

Rank: Member
Groups: Member

Joined: 9/3/2013
Posts: 16
eo_support
Posted: Thursday, May 28, 2015 2:20:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Yes. You can use Fiddler.
Fractus
Posted: Monday, June 8, 2015 10:58:53 AM

Rank: Member
Groups: Member

Joined: 9/3/2013
Posts: 16
Hello,

I detected the problem and yes is a security problem, in development is random in a farm always fails, this is SharePoint with Windows Auth.

HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4;
HtmlToPdf.Options.PreserveHighResImages = false;
HtmlToPdf.Options.JpegQualityLevel = 90;
HtmlToPdf.Options.GeneratePageImages = true;
HtmlToPdf.Options.MinLoadWaitTime = 5000;
HtmlToPdf.Options.PageSize = new System.Drawing.SizeF(PdfPageSizes.A4.Height, PdfPageSizes.A4.Width);
HtmlToPdf.Options.VisibleElementIds = "panelanalisis";
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.ShrinkToFit;
HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.OutputArea = new RectangleF(0.25f, 0.25f, 10.75f, 8.0f);
string cBaseURL = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
HtmlToPdf.Options.BaseUrl = cBaseURL.ToLower();
string cURLFile = SPContext.Current.Site.Url + "/" + SPContext.Current.File.Url + "?" + this.Page.Request.QueryString.ToString();
HtmlToPdfResult oResultHtmlToPdf = HtmlToPdf.ConvertUrl(cURLFile.ToLower(), pdfStream);//SPContext.Current.Site.Url + this.Page.Request.RawUrl, pdfStream);
pdfStream.Position = 0;
byte[] contents = ReadFully(pdfStream);

System.Exception: EO.Pdf.HtmlToPdfException: Failed to convert Url 'http://qaapp.fractus.cl/sites/acco/pages/analisiscuenta.aspx?cuentaid=3951&periodo=08052015&divisionid=28&form=26&tipocuenta=activo+corriente&desc=cajas&acccid=440'.(401:The requested resource requires user authentication. This is an error returned by the Web server, not by the HTML to PDF converter. Please try to visit the same Url with your browser to verify whether the Url is valid.)
at EO.Pdf.Internal.c8.a(String A_0, Boolean A_1)
at EO.Pdf.Internal.c8.b(HtmlToPdfOptions A_0, String A_1, Boolean A_2)
at EO.Pdf.Internal.c8.a(br A_0) at EO.Pdf.Internal.lm.c.a(Byte[] A_0)
at EO.Pdf.Internal.a.b(BinaryReader A_0)
at EO.Pdf.Internal.lm.a(a A_0)
at EO.Pdf.HtmlToPdfSession.a(a A_0)
at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options)
at EO.Pdf.HtmlToPdf.ConvertUrl(String url, Stream stream, HtmlToPdfOptions options)
at EO.Pdf.HtmlToPdf.ConvertUrl(String url, Stream stream)
at Fractus.ACCC.wpFormularios.wpFormulariosUserControl.btnAprobar_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Fractus - Developer & Consulting


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.