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 and breaks <br />


I try to use breaks in some html text in a PdfHTMLTextElement. But they do not seem to work. I do not get any errors either. I used the example on on https://help.syncfusion.com/file-formats/pdf/working-with-text#adding-a-html-styled-text

According to the help page a BR is a supported tag.

I added some breaks to the example. But the do not show in the generated PDF:

//Simple HTML content

string htmlText = @"<font color='#0000F8'>Essential<br /><br />PDF</font> is<br /><br /> a <u><i>.NET</i></u><br /><br /> " +

"library <br /><br /> with the capability to <br /><br /> produce Adobe PDF files ";

6 Replies

MA M Angent April 6, 2017 07:37 AM UTC

To answer my own Question. BR does not seem to work. Replacing the BR tags for 'Environment.NewLine', or '\r' does seem to work.

   string htmlText = "<font color='#0000F8'>Essenntial\r\rPDF</font> is" + Environment.NewLine + Environment.NewLine + " a <u><i>.NET</i></u>" + Environment.NewLine + Environment.NewLine + " " +

            "library " + Environment.NewLine + Environment.NewLine + " with the capability to " + Environment.NewLine + Environment.NewLine + " produce Adobe PDF files ";

PV Prakash Viswanathan Syncfusion Team April 6, 2017 09:12 AM UTC

Hi Angent, 
Thanks for contacting Syncfusion support. 
On our analyze with the HTML document, the break tags contain spaces in between, so that our converter could not recognize the breaks. We suggest you to remove the spaces in the break tag (<br/>) then it will work fine. We have attached the output document for your reference. 
Please try the below modified HTML text and let us know the result. 
//Simple HTML content 
string htmlText = @"<font color='#0000F8'>Essential<br/><br/>PDF</font> is<br/><br/> a <u><i>.NET</i></u><br/><br/> " + 
"library <br/><br/> with the capability to <br/><br/> produce Adobe PDF files "; 
Prakash V 

LA Laz June 27, 2020 06:52 AM UTC

I had the same issue...tried various combinations, didn't think to try <br/>, since that is non-standard syntax. The standard syntax would be: HTML:<br>XHTML:<br />.

I wish Syncfusion's PDF component were maintained, because oddities like this make it very cumbersome and un-intuitive to use. This is a basic problem that (1) should be well-documented on the relevant pages, specifically: 


And (2) the parser should accept the official xhtml tag, which is <br /> and ideally the standard html tag, which is <br>.

Instead the developer is left scratching his head and wasting time unnecessarily on a simple problem. I myself stumbled upon this solution by accident while browsing the forum trying to figure out another problem, after I gave up on finding a solution days ago.

SL Sowmiya Loganathan Syncfusion Team June 29, 2020 12:41 PM UTC

Hi László,  

We have analyzed your requirement and currently we are validating on this and will update the further details on July 01, 2020.  

Sowmiya Loganathan 

RB Ravikumar Baladhandapani Syncfusion Team July 1, 2020 02:36 PM UTC

Hi László,  
We have confirmed that the issue with “Change the standard break tags in HTML which contain space while adding styled text in PDF” is a defect. We will include this fix in upcoming weekly nuget release and which will be expected available on July 14th ,  2020. 
Please find the feedback link from below,       

SL Sowmiya Loganathan Syncfusion Team July 14, 2020 12:04 PM UTC

Hi László,  
Thank you for your patience. 
As promised earlier we have included the fix for the reported issue “Change the standard break tags in HTML which contain space while adding styled text in PDF" in our latest released weekly NuGet release (v18.2.0.45). Please use the below link to download our latest weekly NuGet,  
Please let us know if you have any concerns on this.  
Sowmiya Loganathan 

Live Chat Icon For mobile
Up arrow icon