HTML to PDF Creation issue

Hi,


I am trying to generate PDF using HTML. I am using "WebKitConverterSettings" in which I have set "EnableRepeatTableHeader" to true. What I am facing issue right now is Headers are overlapping with the image as you can see in the below screenshot. I have attached project in the attachment section. Please look into that let me know why is that occuring.



 


Attachment: htmltopdfcore953387620_f3469476.zip

1 Reply

PV Prakash Viswanathan Syncfusion Team July 29, 2021 03:21 PM UTC

Hi Sheeban, 

We have checked the reported header overlap issue with images. We internally make use of QtWebKit rendering engine for converting HTML to PDF. The reported issue occurs with QtWebKit rendering engine itself. So, we are unable to proceed this issue with QtWebKit rendering engine.  

However, can you please try with our latest Blink rendering engine. It supports latest features from web technologies such as scripts, styles etc., We have converted the provided HTML string to PDF with Blink rendering engine, the header not overlaps with images. Please find the document and code snippet below, 

Code snippet: 
            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink); 
            BlinkConverterSettings settings = new BlinkConverterSettings(); 

            settings.PdfPageSize = PdfPageSize.Letter; 
            settings.Margin = new Syncfusion.Pdf.Graphics.PdfMargins { Top = 0, Left = 30, Right = 30, Bottom = 0 }; 

            settings.EnableToc = true; 
            settings.MediaType = MediaType.Print; 

            settings.PdfHeader = AddHeader(settings.PdfPageSize.Width, "Syncfusion Essential PDF", " "); 
            settings.PdfFooter = AddFooter(settings.PdfPageSize.Height, "@Copyright 2021"); 

            //Set WebKit path 
            settings.BlinkPath = @"C:\Users\xxx\.nuget\packages\syncfusion.htmltopdfconverter.blink.net.core.windows\19.2.0.44\lib\BlinkBinariesWindows"; 
             
            //Assign WebKit settings to HTML converter 
            htmlConverter.ConverterSettings = settings; 

            MemoryStream stream = new MemoryStream(); 
            //HTML string and base URL  
            string baseUrl = string.Empty; 
            //PdfDocument document = htmlConverter.Convert("D:/table.html"); 
            PdfDocument document = htmlConverter.Convert(@"<!DOCTYPE html><html><head></head><body>body></html>", baseUrl); 

            document.Save(stream); 
            document.Close(); 
                                 
Regards, 
Prakash V 


Loader.
Up arrow icon