Syncfusion is used to convert webpages, SVG, MHTML, and HTML to PDF. Using this library, you can preserve resources such as image, scripts, and CSS during HTML text to PDF conversion. While converting HTML string to PDF, you have the option to specify the base URL. The base URL is a path of the resources used in the HTML string.
You can get all the previously mentioned assemblies and QtBinaries by installing the HTML converter installer available in the following link.
HTML Converter: https://www.syncfusion.com/downloads/latest-version
NuGet Installed location: C:\Users\<<user name>> \.nuget\packages\syncfusion.htmltopdfconverter.qtwebkit.winforms\XX.X.X.XX\lib.
For the previous HTML string, provide the path of syncfusion_logo.gif as baseURL.
For example, if the above image is in “D:/temp/Resources/syncfusion_logo.gif” location, then the baseURL will be as follows,
Example baseURL: D:/temp/Resources/
Find the possible causes and solutions for missing resources while converting HTML string to PDF:
To convert or access the HTTTS sites, the HTML converter requires OPENSSL assemblies. If the base URL is HTTPS, make sure that your machine/server has the OPENSSL assemblies. Refer to the for more information.
The following assemblies are placed in the windows system folder (for 64-bit machine, it should be placed in $SystemDrive\Windows\SysWOW64 and for 32-bit machine, it should be placed in $SystemDrive\Windows\System32),
While converting HTML string to PDF with base URL, the HTML string with Base URL is internally saved into temporary HTML file and use this file for further conversion. So, that the browser/converter can access the resources such as styles, images, and scripts from the provided base URL.
The HTML converter preserves the output PDF document as the temporary HTML file that is displayed in web browser. So, create a temporary HTML file with HTML string and base URL, and check the contents in the web browser.
Refer to the following steps to create a temporary HTML file.
1. Copy the input HTML string and save it as a HTML file.
2. Open the HTML file in text editor and include the Base URL as base href in header tag as follows.
3. Save and view the HTML file in browser and check the contents.
This page will automatically be redirected to the sign-in page in 10 seconds.