We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Formatting error. Spacing/tabs is being removed

I’m trying to add multiples spaces/tabs in a text string. When the PDF is created all the spaces are removed. Any suggestions as to what I can do to keep the formatting?

In the example below all the spacing between firstname and lastname is removed.

var htmlText = "

firstname lastname




"
var text = new Text(htmlText);
text.IsHtmlTagSupported = true;
document.Sections[0].Paragraphs.Add(text);




Hi Andres,


Thanks for contacting support.

I have tested the scenario and have observed that when viewing the HTML contents inside Web browser, the blank spaces are removed and no space appear between characters. However in order to place space between words, you need to try using   character to render space between words. Please try using following code snippet. For your reference, I have also attached the resultant PDF generated over my end.

[C#]

Pdf document = new Pdf();<o:p></o:p>

document.Sections.Add();

var htmlText = "

firstname                   lastname




";

var text = new Text(htmlText);

text.IsHtmlTagSupported = true;

document.Sections[0].Paragraphs.Add(text);

document.Save("c:/pdftest/HTMLSpacing.pdf");