Hello,
I've been using the WebKitConverter for converting an Html page with some charts into a PdfDocument, in this case I'm creating a PDF document and inside the last page I'm drawing the converted Html page.
I managed to make it work but I stumbled into a very strange behaviour:
- when debugging the code on my local machine it works perfectly
- when debugging the code on our Server it works perfectly
- after the deploy on IIS on our Server the Html template, when drawn inside the pdf, has a width larger than the pdf with some content going over the margins
All the debug is done using Visual Studio 2019, QtBinaries are imported correctly and the dll files for OPENSSL are there too.
In those first two cases my html contains a table and two charts that are shown correctly inside the margins of my pdf page, in the third case the html is the same as before but when converted the table and the charts are much higher and the width is greater than the available, resulting in some content cut from the borders.
Is there any settings inside IIS that may cause this behaviour?
This is the code I've been using:
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings converterSettings = new WebKitConverterSettings();
converterSettings.WebKitPath = $"{dir}\\QtBinaries";
converterSettings.AdditionalDelay = 2000;
htmlConverter.ConverterSettings = converterSettings;
PdfDocument docWeb = htmlConverter.Convert("myurl");
using (MemoryStream stream = new MemoryStream())
{
docWeb.Save(stream);
PdfLoadedDocument htmlDocument = new PdfLoadedDocument(stream);
PdfTemplate htmlTemplate = htmlDocument.Pages[0].CreateTemplate();
graphics.DrawPdfTemplate(htmlTemplate, new PointF(-20, layoutResult.Bounds.Bottom + 20));
}
The delay is used for waiting the charts to be initialized completely. I tried to add these following options but the result didn't change:
converterSettings.AspectRatio = AspectRatio.FitPageSize;
converterSettings.EnableJavaScript = true;
converterSettings.SinglePageLayout = Syncfusion.Pdf.HtmlToPdf.SinglePageLayout.FitWidth;
converterSettings.PdfPageSize = new SizeF(page.Size.Width, page.Size.Height);
In the attachment you can find a screenshot of the problem (left window is debug in localhost, right window is the one from IIS)
Regards,
Daniele
Attachment:
Syncfusion_pdf_error_72851c79.zip