Free Support Forum -

Format of HTML to pdf conversion

I have a .NET application and I want to convert a dataset to .pdf output by applying an xsl transformation.

My first attempt was to try and apply the transformation via aspose.pdf but this produced no output. So my first question is:
Does aspose .pdf require some special xml elements and thus the xml document must be first created via aspose.excel (as suggested by your response to another thread)?

I have then adopted the approach of first converting to an HTML memory stream (using the .NET XSLTransform object) and using the latest patch for Aspose.pdf converting the memory stream to pdf with:

pdf.Save(“x1.pdf”, SaveType.OpenInAcrobat,Response)

This produces a pdf document which can be opened in the browser (by the way, is there a convenient way of trusting the dummy file “x1.pdf” so that the user is not asked, twice, if it is OK to open it?).

Unfortunately, the output seems to ignore all the formating (fonts, table column widths etc) and truncates the right-hand side of the page.

So my final question:

Does aspose.pdf only handle a subset of HTML formatting styles (if so, where is this documented) or is there some additional formatting that has to be specified to aspose.pdf?


PS We are on the point of purchasing licences but these issues are holding us up.

Dear njr,

Thank you for considering Aspose.

1) Aspose.Pdf does need special xml format. You can use Aspose.Excel to produce such xml. You can also write the xml yourself and use the ImportArray or ImportDataTable to import your data into the pdf document.

2) As for the dummy file “x1.pdf”, the problem should due to the browser setting. Some version of IE has this bug.

3) Some advanced formatting of HTML will be ignored when converting HTML to pdf. But it should not ignore all formatting info.

I will notify Goergie, the developer of HTML2PDF to confirm problem 2 and 3. But I recommend you using XML but not HTML. If you have any problem using XML you can post questions in the forum and we’d like to help you.

Thank you for your prompt response but I am still somewhat at a loss.

You suggest that I stick with XML rather than HTML. No problem. Put simply I have the following requirement:
A dataset (whose number of tables, content etc can vary).
For a given dataset, a link to a specific XSL file that “understands” the structure of the dataset (and can produce HTML tables etc through the use of XMLTransform).

Required: To produce formatted .pdf output.

You advise that I cannot just load an XML document (derived from the dataset) into a pdf object and apply the XSL though the use of pdf.BindXML as aspose.pdf requires that the XSL conform to its own model. OK

You suggest that I load the individual datatables from the dataset into the pdf object using “ImportDataTable”. This however seems to require the definition of the layout for the pdf.table to be pre-defined and this is precisely the information that is in the XSL file.

Am I missing something here? Is there no straightforward way of converting a standard XML document to a pdf file by applying a standard XSL style?

Do I have to rewrite all the XSL documents to use the aspose namespace and tags?

Thanks in anticipation

Dear njr,

Thank you for considering Aspose.

Sorry for misunderstanding your requirement in the former post. It seems using HTML2PDF is the better way for you. If you use XML + xslt or XML + DataTable, you have to rewrite the layout tags.

So let us see if we can help you to work with HTML2PDF. Can you please send a example HTML file to Georgie (the developer of HTML2PDF)?


I will send a sample from my development machine

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

I'm having the same problem. sending email to George(as mentioned)

I also sent my html file in the email.

I was playing around with different settings and found , it seems pdf doesn’t understand this line

anything says "style", pdf is not converting.

Contact Name

If I change the above line like this,

Contact Name

Then it works. ?!




I have supplied sample data as requested. Is there any progress?


Dear njr,

Thank you for considering Aspose.

We have received your mail and we are now trying to solve the problem. Georgie will reply to you soon.

Dear vgopinath,
Thank you for considering Aspose.

style attribute is css style, we don't support now. You can advert our blog for our plans and releases list.
Best Regards
Dear vgopinath,
Thank you for considering Aspose.

style attribute is css style, we don't support now. You can advert our blog .
Best Regards

Dear njr,
Thank you for considering Aspose.
1) In the lastest release of aspose.pdf, when converting .html to .pdf, some formatting info will be lost, especially table formattings. We are plan to improve the table generate effect in next releases. You can advert the blog for our plans and releases list.
2) Though it is a better way to use html than xml, If you write a similar application, I suggest that you can write a xslt that can produce the xml file that according with aspose.pdf, then you can use BindXml() directly to generate .pdf.

Best Regards
Georgie Yuan
Aspose Changsha