We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PdfHTMLTextElement not rendering style

Hi, 

I'm evaluating the htmltopdf functionality. 
I've got a string with a style tag containing a color and text-align attribute 

PdfHTMLTextElement texthtml = new PdfHTMLTextElement();
texthtml.HTMLText = "<p style=\"color: red;text-align: left\">This is a red text align left</p>";                                                              
PdfLayoutResult res = texthtml.Draw(currentPdfPage, new Rectangle(20, 20, page.GetClientSize().with, page.GetClientSize().Height), new PdfMetafileLayoutFormat { Break = PdfLayoutBreakType.FitPage, Layout = PdfLayoutType.OnePage });

From this ressource Working with Text, PdfHTMLTextElement support for a basic HTML tags but not the style tag. 
Is there any way to render the text-align property with a PdfHTMLTextElement  ?

thanks,



3 Replies

PV Prakash Viswanathan Syncfusion Team July 26, 2017 11:48 AM UTC

Hi Vincent, 
 
Thanks for contacting Syncfusion support. 
 
The PdfHTMLTextElement class provides only basic set of HTML tags to render in the PDF document. HTML with CSS are not supported in this class, so we could not align the text using PdfHTMLTextElement class. To convert complex HTML, HTML with CSS and URL to PDF, we suggest you to try our WebKit HTML converter. Please refer below links for more information of our WebKit HTML converter, 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Prakash V 



VP Vipul Patodi June 1, 2023 03:55 PM UTC

Is it still true? We are not allowing css like Right Align with  PdfHTMLTextElement ?



SN Santhiya Narayanan Syncfusion Team June 5, 2023 08:37 AM UTC

yes. we introduced a new Blink rendering engine, which supports the latest bootstrap styles and advanced web features. We are fully focused on this and suggested the blink rendering engine. Blink converter internally makes use of chromium executable in headless mode for converting HTML to PDF. It will preserve the PDF document like how the input HTML is displayed in chromium-based web browsers (chrome print preview).

Please refer below link for more information about the Blink rendering engine.

Blink: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/net-core

NuGet link: https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/

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



Loader.
Live Chat Icon For mobile
Up arrow icon