Image is not showing after converting Html File Or Html string into PDF

Hi ,

I have Html document "or" i am creating a html string and after creating html document "or" html string , i am converting this doc with pdf using Syncfusion Html to pdf approach , everything works file but after added image into my html image is not displaying on pdf doc and in html document image is displaying.

Below is my HtmlCode:

<html><body><table align="center" width="100%" cellpadding="0" cellspacing="0" border="0" style="border: 3px solid #000000;"><tr><td colspan="2"valign="top" style="padding: 10px; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 25px;"><table align="center" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td valign="top">Frank Haegland</td></tr><tr><td valign="top">Line 12345 Line 21</td></tr><tr><td valign="top">Ashok Nagar Location, Ashok Nagars 11100971, India</td></tr><tr><td valign="top">(978)978-9789</td></tr><tr><td valign="top">[email protected]</td></tr></table></td><td colspan="2" valign="middle" style="padding: 10px; font-family: arial; font-size: 31px; font-weight: bold; color: #000000; line-height: 44px; text-align: center;">Estimate Invoice Receipt</td></tr><tr><td width="55%" valign="top" style="border-bottom: 3px solid #000000; border-right: 3px solid #000000; border-top: 3px solid #000000; padding:10px; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 20px;">Date: 7/19/2018 2:30:52 PM</td><td width="15%" align="center" valign="top" style="border-bottom: 3px solid #000000; border-right: 3px solid #000000; border-top: 3px solid #000000; padding:10px; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 20px;">Daily</td><td width="15%" align="center" valign="top" style="border-bottom: 3px solid #000000; border-right: 3px solid #000000; border-top: 3px solid #000000; padding:10px; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 20px;">SubTotal</td><td width="15%" align="center" valign="top" style="border-bottom: 3px solid #000000; border-top: 3px solid #000000; padding:10px; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 20px;">Total</td></tr><tr><td valign="top" style="border-right: 3px solid #000000; padding: 10px 0 0 10px; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 25px;">Lodging 8 Days</td><td valign="top" align="right" style="border-right: 3px solid #000000; padding: 0 10px 0 0; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 25px;"></td><td valign="top" align="right" style="border-right: 3px solid #000000; padding: 0 10px 0 0; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 25px;"></td><td valign="top" align="right" style="padding: 0 10px 0 0; font-family: arial; font-size: 16px; font-weight: normal; color: #000000; line-height: 25px;"></td></tr></table></body></html>

and My C# Code is:

 System.IO.File.WriteAllText("MyTest123.html", content);
            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
            WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
            webKitSettings.WebKitPath = "QtBinaries";
            webKitSettings.EnableJavaScript = true;
            htmlConverter.ConverterSettings = webKitSettings;
            Syncfusion.Pdf.PdfDocument document = htmlConverter.Convert("MyTest123.html");
            document.Save("MyTest234.pdf");
            document.Close(true);


Thank you




3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team July 26, 2018 05:02 AM UTC

 Hi Vaibhav, 
Thank you for contacting Syncfusion support. 
To preserve the resources such as CSS, Images etc during the HTML to PDF conversion, you have to mention the location of the resources through the BaseURL argument. Please find below link for to get more details. 

Code Snippet: 
Syncfusion.Pdf.PdfDocument document = htmlConverter.Convert(content, “/path/to/your/resource”); 
 
Please let me know if you need any further assistance in this else you may proceed to mark this incident as closed. 
Regards, 
Karthikeyan 



TA Tawani Anyangwe March 31, 2021 03:07 PM UTC

Images do not show up when the baseUrl is an HTTPS. It works with HTTP but not with HTTPS.


GK Gowthamraj Kumar Syncfusion Team April 1, 2021 08:55 AM UTC

Hi Tawani, 

Thank you for contacting Syncfusion support.   
  
We suspect the reported issue may occur due to the missing of OPENSSL assemblies on your end. The images are accessed from HTTPS URL, WebKit HTML converter requires OPENSSL assemblies to be installed in the machine for accessing the resources from HTTPS. So, please make sure the OPENSSL assemblies are available in the machine where the conversion takes place. If it is not available, OPENSSL assemblies can be placed in the Windows system folder of the machine, and try the conversion in your project and let us know the result.    
  
Please refer to the below UG links for more information,   
  
However, the below mentioned OPENSSL assemblies can be placed in the Windows system folder of the machine. (for 64-bit machine, it should be place in $SystemDrive\Windows\SysWOW64 and for 32-bit machine, it should be place in $SystemDrive\Windows\System32).  
  • libeay32.dll
  • libssl32.dll
  • ssleay32.dll

If still, you are facing the same issue, then kindly try the additional delay to the converter for loading the external resources (images, etc.,). Can you please try the conversion with additional delay and let us know the result. Please refer to the below code snippet to set the Additional Delay property to converter settings,    

//Set additional delay; units in milliseconds  
Settings.AdditionalDelay = 4000;  

Please refer to the below links for more information about Additional delay,    
  
Please try the above suggestions and if still, the same issue occurs, kindly provide more details such as complete input HTML file (with all resources styles, images, scripts, etc.,), complete code snippet, output document, product version to check the issue in our end. So, that it will be helpful for us to analyze and assist you further on this.   
 
Regards, 
Gowthamraj K 


Loader.
Up arrow icon