Fonts are not preserved properly when using html to pdf conversion library

Hi Team,

I am using the Syncfusion html to pdf library to convert the html string to pdf in my project. I am able to set the width of the content using the Blink Converter Settings (ViewPort). But the fonts are not matching the original html string. Kindly let me know the solution for this.

Attached the images of generated PDF.

Generated PDF using other third party library:

Image_7726_1710174335238

Generated PDF using Syncfusion library:

Image_6678_1710174227443


Thanks,

Jagadish


Attachment: html_syncfusion_9aa0de87.zip

3 Replies

KS Karmegam Seerangan Syncfusion Team March 12, 2024 06:49 AM UTC

Hi Jagadish,


Thank you for reaching out to Syncfusion support.

 

Our HTML converter internally uses the Blink rendering engine. It utilizes a Chrome headless browser for converting HTML to PDF. It will preserve the PDF document in the same way as the input HTML/URL is displayed in Chromium-based web browsers such as Chrome and print preview. Our converter replicates this same behavior.

 

We have checked the provided HTML text in Chrome print preview, and the same result was replicated in our converter. However, we have attached the sample, output document, and screenshot for your reference.

 

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Blink_Font_Issue1739413158

Output: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HTML-to-PDF1256193119

 

Chrome print preview screenshot:

image

 

Syncfusion screenshot:

Terms and Conditions 
TERMS CONDITIONS AND SIGNATURES (the "Agreement") 
By signing below, Participating Member agrees that: 
• Participating Member hereby designates Premier Healthcare All • 
CP. ("Premier") to act as 
Participating Member's group purchasing agent for the products 
services (collectively, "Products") 
purchased by Participating Member through the group purchasinörogram ("Program"). 
• Participating Pvlember will use Premier as its primary group 
asing organization. 
• Participating Member vhll use all Products it purchases 
r group purchasing contracts of Premier and, 
if applicable, the sponsor named on the first 
this Agreement ("Sponsor") solely for its own 
operations and will not re-sell any such Prod* except to the extent Participating Member is a OME 
provider or retail pharrnacy that is purchasin 
Program vendors ("Vendors") who offer pricing to OME

 

Kindly try the provided sample and let us know the result. If you are still facing issues, we kindly request you to share the modified sample, complete code snippet, package name, package version, and environment details with us to replicate the same issue on our end. It will be more helpful for us to analyze and provide you with a prompt solution.


Regards,

Karmegam



JA Jagadish March 12, 2024 11:01 AM UTC

Hi Karmegam,

I have attached the files to find the difference of the fonts. You can see the difference in the Terms and conditions section.

Packages used:

<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="24.2.9" />

<PackageReference Include="Syncfusion.Licensing" Version="24.2.9" />

Syncfusion code:

//Initialize HTML to PDF converter

HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();


//Initialize blink converter settings.

BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

//Set Blink viewport size.

blinkConverterSettings.ViewPortSize = new Size(420, 0);

//Assign Blink converter settings to HTML converter.

htmlConverter.ConverterSettings = blinkConverterSettings;


//Convert URL to PDF

PdfDocument document = htmlConverter.Convert(membershipApprovalDoc, _sharePointOptions.FilesUploadTempFolder);

FileStream fileStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite);

//Save and close the PDF document.

document.Save(fileStream);

document.Close(true);

Thanks,

Jagadish


Attachment: iText7_Membership_Documentation_Acceptance_PDSLaceyModernD_ContinuumOfCare_11_03_2024_05_29_21_7356a00.zip



KS Karmegam Seerangan Syncfusion Team March 13, 2024 10:33 AM UTC

Thank you for providing the details. As we mentioned previously, we have checked the provided input HTML in Chrome print preview, and the same result was replicated in our converter. However, we have modified the input HTML for your expected result. Please find the below screenshot.

image



Modified HTML: https://www.syncfusion.com/downloads/support/directtrac/general/ze/html_syncfusion-369801006

Output document: https://www.syncfusion.com/downloads/support/directtrac/general/ze/HTML-to-PDF-1046199231

 

Kindly check your input HTML input file in Chrome's print preview. Kindly try the provided solution and let us know the result.



Loader.
Up arrow icon