Html to Pdf Css and Size

I am trying to convert html string to pdf using webKit code sample and the pdf is not like the css design in the html file and it is nor covering the whole page.

The html plain text file and the Pdf result is attached.

Any Ideas ?


the code is:

string html; 

string htmlPath = @"C:\Temp\Document.html"; 

html = System.IO.File.ReadAllText(htmlPath);

htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); 

WebKitConverterSettings settings = new WebKitConverterSettings(); 

settings.WebKitPath = @"C:\Temp\QtBinaries\"; 

htmlConverter.ConverterSettings = settings; 

PdfDocument document = htmlConverter.Convert(html, ""); 

document.Save(@"c:\temp\1.pdf"); 

 document.Close(true);


Attachment: pdf_f2701906.zip

1 Reply

GK Gowthamraj Kumar Syncfusion Team April 25, 2022 10:45 AM UTC

Hi Yaron,

We have checked the reported issue with HTML to PDF converter. Our HTML converter internally make use of Qt WebKit rendering engine for converting HTML to PDF. WebKit rendering engine preserves the output PDF document like how the input HTML file/URL is displayed on the WebKit based web browsers (safari, internal tool). The reported style issue occurs in QtWebKit itself. The same behavior as replicates in our converter. We have attached a screenshot of the provided webpages view in safari browser for your reference. So we could not proceed further with WebKit rendering engine.


Safari browser:


However, the provided HTML file is converted properly in our Blink rendering engine. The provided HTML is rendered as expected in Blink conversion. Blink rendering engine internally using a chrome headless browser for converting HTML to PDF. It will preserve the PDF document like how the input HTML is displayed in chromium-based web browsers (chrome). Kindly please try our latest Blink rendering engine and let us know if it is suites your requirement.

Blink: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/blink

https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf#supported-and-unsupported-features-by-rendering-engines


Please try the above suggestions in your end and let us know if you need any further assistance on this.


Regards,

Gowthamraj K


Attachment: BlinkOutput174593_2ce1f956.pdf

Loader.
Up arrow icon