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

Free Support Forum - aspose.com

How to apply css style to the pdf file

Hi there,

I’m generating pdfs from the HTML output from a Rich Text Editor. But the output html displays differently in the pdf, e.g. different line spacing and

    list missed punctuation after the numeric points etc.

    Is there a way to apply css style into the pdf?

    I’m using the versino 4.0.

    Thanks for your time!


Hello Lily,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

If you need to display the output with proper formatting, you need to specify the HTML tags within the text segment. Please visit the following link for more information on HTML Tags in Text

I case it does not satisfy your requirement or you've any further query, please feel free to contact.

Hi there,

Thanks for the reply.

We’re pretty happy with Aspose.Pdf kit so far t is working great in the project i!~

Just an extended question: when output a html block which include tags, the bold word will be rendered in Times New Roman font style even I set up the text block textinfo font name as Arial.

Is there a way to avoid this?

Thanks!

Regards,

Lily

Hello Lily,

Thanks for considering Aspose.

Please try using the following code snippet to accomplish your requirment.

[C#]

//Instantiate a pdf document
Pdf pdf1 = new Pdf();
//Create a section in the pdf document
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Create string variables with text containing html tags
string s = "" + "This is a test for ARIAL </ Font support " + " in Text paragraph. ";

string s2 = "

This is a test for" + " Verdana in text paragraph.

";

//Create text paragraphs containing HTML text
Text t1 = new Text(s);
t1.IsHtmlTagSupported = true;
Text t2 = new Text(s2);
t2.IsHtmlTagSupported = true;

//Add the text paragraphs containing HTML text to the section
sec1.Paragraphs.Add(t1);
sec1.Paragraphs.Add(t2);

//Save the pdf document
pdf1.Save("d:/pdftest/TestHtml.pdf");