Custom Font in HTML to PDF Converter (Blazor)

Hello,

is there a way to use a custom font with the  Syncfusion.HtmlConverter.HtmlToPdfConverter in Blazor?
How to link the resource/font file to the stylesheet i attached the html string?
With standard fonts like Arial or Verdana its working, but not with custom fonts (its only italic).

If this is possible, maybe u can prepare a demo file for me?

Thanks,
Nils


6 Replies

NS Nils Steinle November 15, 2021 03:19 PM UTC

Here an example:

I've added the Font 'Montserrat', it seems to be loaded, but only italic. I've added the normal, not italic font.


The final HTML to PDF File:

Screenshot 2021-11-15 161649.png



GK Gowthamraj Kumar Syncfusion Team November 16, 2021 01:36 PM UTC

Hi Nils, 

Thank you for contacting Syncfusion support. 

We have tried to reproduce the reported issue with provided font details on our end, but it is working properly and font preserve with its regular styles. We were not able to reproduce the reported font preservation issue. We have attached the sample for converting Html (with custom font) to PDF document using Blazor application. Please try the sample with your input files on your end and let us know the result. 



If still you are facing the same issue, kindly provide more details such as modifies sample or complete input HTML file/URL (with resource style, fonts, scripts , etc.,), complete code snippet, Environment details (OS, bit version, culture settings, RAM size, etc.,), 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 



NS Nils Steinle November 16, 2021 02:19 PM UTC

Hello,

thanks for your fast response.

The issue still occurs:


Montserrat Thin


Montserrat Regular



The new Testproject (too big for the file upload in forums):

https://shorturl.at/bfwzD


I attached my fonts to the testproject so u can test it (its original montserrat-thin from google fonts, and not Italic) but it is still italic...

You can open the attached fonts in the "HTMLFile"-Folder and u can see its not the italic one...


thanks,

Nils





GK Gowthamraj Kumar Syncfusion Team November 17, 2021 09:25 AM UTC

Hi Nils, 
 
Thank you for your patience.

 
We have checked the provided sample on our end, we were able to get the reported font rendering issue. WebKit rendering engine internally make use of QtWebKit rendering engine for converting HTML to PDF, the reported issue occurs with QtWebKit rendering engine itself. We have already added this “HTML to PDF conversion with CSS injection in WebKit” to our feature request list and we will implement this feature in any of our upcoming release. But we do not have any immediate plans to implement this feature. We usually have an interval of at least three months between releases, at the planning stage of every release cycle, will review all the open features and we will notify you once this support is implemented.  

The feature request can be tracked through our Features Management System:     

To overcome this issue, kindly try our latest Blink rendering engine which preserves output PDF document like how the input HTML file displayed in chrome web browser. This rendering engine support more styles and HTML features when comparing to WebKit rendering engine. Please refer below links for more information,   

We have tried the Blink Html to PDF conversion with provided font details, it working properly. Please find the sample and output document from below,
Sample: https://www.syncfusion.com/downloads/support/forum/170398/ze/BlazorHTMLToPDF_Blink642057055 
 
Note: Blink rendering engine does not support conversion in Azure app service (Azure websites) and Azure function.  
 
Please let us know if you need any further assistance with this. 

Regards, 
Gowthamraj K 



NS Nils Steinle November 17, 2021 09:43 AM UTC

With blink it works perfectly. So I will just use Blink. Thank you for the advice and for your efforts.



GK Gowthamraj Kumar Syncfusion Team November 17, 2021 09:47 AM UTC

Hi Nils, 

Thank you for your update and confirmation. We are glad to know that the suggested Blink solution resolved your problem. 

Please let us know if you need any further assistance with this. 

Regards, 
Gowthamraj K 


Loader.
Up arrow icon