Hello,
My organization is using the Aspose.PDF library to convert HTML to PDF. We would also like to be able to convert XML to PDF. Ideally, we’d like a result similar to what an XML document looks like when it’s rendered in Internet Explorer or, if a stylesheet exists, the stylesheet would be rendered appropriately. Is it possible to accomplish this task using the Aspose.PDF library (or any other Aspose library)?
Thank you.
Hi Mark,
Thanks for contacting support.
Aspose.Pdf for .NET offers the feature to convert XML files to PDF format but the resource XML should be in Aspose.Pdf compatible format (according to DOM of Aspose.Pdf for .NET).
You may consider visiting following link for further information on
[C#]
// load XML file
XmlLoadOptions xmlfile = new XmlLoadOptions();
Document doc = new Document(@"C:\pdftest\source.xml", xmlfile);
// Save resultant PDF
doc.Save(@"C:\pdftest\_updated.pdf");
Hello,
I have attempted to follow the example you provided and my result is always a blank 1 page PDF. Any ideas on why that may be the case?
Thanks
I have a sample app created showing the issue. What is the best way to send it?
Hi Mark,
Please remove the product binaries and attach the solution in this forum thread. Also please ensure that license file is not included in package.
Here is everything. I have included two sample XML files and an XLS file. One of the XML files has a reference to XLS directly in it, the other does not and was passed into the XmlLoadOptions. Both yield the same result.
Hi Mark,
Thanks for sharing the resource files.
The reason resultant PDF being generated is blank because input file is not according to DOM of Aspose.Pd for .NET. As shared earlier in 689968 post , please make your XML file compatible to Aspose.Pdf acceptable format and then try XML to PDF conversion.
We are sorry for this inconvenience.
PS, in case you are using XSL-FO, it can be converted directly to PDF format using XslFoLoadOptions class.
Hi Mark,
Thanks for sharing the details.
In case you need to use your own XML files, please make them compatible with Aspose.Pdf for .NET by using XSLT. Furthermore, the files shared on W3 website, they are general files and not according to our Document Object Model.
You may consider using either of the following approach to convert XML file to PDF format
Why is every link on your website dead. Cannot find any proper examples
@PhilipHill,
Please refer to the Developer Guide of Aspose.Pdf for .NET API: Developer Guide and let us know for any further assistance or questions.