Aligning text in a div when converting html to pdf

Hi

I am trying to convert a html page to a pdf, and am having trouble with text alignment in a div. I am using version 5.0.0.

The code in question is:


Your Name


Your Area




with the following css for the class “title” in an external css file:

div.title
{
text-align: center;
font-size: 20pt
}

Is the text-align: css tag supported in version 5 of aspose.pdf? if it is not, what can we use instead to get center alignment for our text?

Thanks

This message was posted using Page2Forum from Working with Text Containing HTML Tags - Aspose.Pdf for .NET

Hello Danielle,

Thanks for using our products.

I am pleased to inform you that the reported issue has been fixed in recent released hotfix Aspose.Pdf for .NET 5.0.1. During my testing with following HTML, CSS and code snippet, I am able to generate correct PDF document over Windows XP SP3. Please try using the latest release version shared over this link and in case you still encounter any problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

[CSS]

div.title
{
text-align: center;
font-size: 20pt;
}

[HTML]

<html>
<head>
<title>Test for Inline style and CSS support </title>
<link rel="stylesheet" href="d:/pdftest/sampleCSS.css" />
</head>

<body>
<div class="title">
<p class="name">Your Name</p>
<p class="areas">Your Area</p>
</div>
</body>
</html>

[C#]

// Instantiate an object PDF class
Pdf pdf = new Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Section section = pdf.Sections.Add();
// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(@"D:/pdftest/HTMLTest.html");
//Create text paragraphs containing HTML text
Aspose.Pdf.Text text2 = new Aspose.Pdf.Text(section, r.ReadToEnd());
// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
// Add the text object containing HTML contents to PD Sections
section.Paragraphs.Add(text2);
//Save the pdf document
pdf.Save("D:/pdftest/CenterAlign-Issue.pdf");