Free Support Forum -

XmlException When Saving ODS to XML and Binding Into a PDF Via Pdf.BindXML()

I’m saving an ODS file to XML and binding the XML file into a PDF via Pdf.BindXML() method. However, I’m getting a XmlException. The ODS file is attached for sample. The exception is:

System.Xml.XmlException was caught
Message= 1, posição 1.
em System.Xml.XmlTextReaderImpl.Throw(Exception e)
em System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
em System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
em System.Xml.XmlTextReaderImpl.ParseDocumentContent()
em System.Xml.XmlTextReaderImpl.Read()
em System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
em System.Xml.XmlDocument.Load(XmlReader reader)
em System.Xml.XmlDocument.Load(String filename)
em (Object , String )
em Aspose.Pdf.Pdf.BindXML(String xmlFile, String xslFile)

I’m using the following source code:
Workbook xls = new Workbook();
xls.Open(pFileName);pTmpFileName = pTmpFileName.Remove(pTmpFileName.IndexOf(pExt));
xls.Save(pTmpFileName +
“.xml”, Aspose.Cells.SaveFormat.Pdf);
Pdf pdfFile = new Pdf();
pdfFile.BindXML(pTmpFileName +
“.xml”, null);pdfFile.SetUnicode();pdfFile.IsImagesInXmlDeleteNeeded = true;
pdfFile.Security =
new Security();
pdfFile.Security.IsPrintingAllowed =
pdfFile.Security.IsDegradedPrintingAllowed =
pdfFile.Security.IsCopyingAllowed =
pdfFile.Security.IsContentsModifyingAllowed =


I looks looks like you are trying to convert the ODS file to xml using Aspose.Cells (intermediate file for Aspose.Pdf to convert it to PDF), but you are using SaveFormat.PDF, which does convert ODS file to PDF directly rather than in xml file, see the document for your reference:

Sample code (I have tested the code and it works fine):
LoadOptions loadOptions = new LoadOptions(LoadFormat.ODS);
Workbook workbook = new Workbook(@“e:\test2\DocCntVer_1110000000157.ods”, loadOptions);
workbook.Save(“e:\test2\out_pdf.pdf”, SaveFormat.Pdf);

Also we do provide options to secure the generated PDF, see the document:

For your information, we now support to directly convert Excel spreadsheets to PDF without any use of Aspose.Pdf component. Also, FileFormatType.AsposePDF is obsoleted and we do not enhance or improve this file format type any more.

Another option can be you may convert the ODS file to PDF and then use Aspose.Pdf product to add security options to further re-save it.

Also, we recommend you to use our latest version i.e. Aspose.Cells for .NET v5.3.2.8

Thank you.

Does Aspose.Words supports this too?


Well, I think so. I would well come my colleagues from Aspose.Words team to comment on it and help you soon.

Thank you.

Your informations were very helpful. Thank you again.

Hi Rogger,

Thanks for your inquiry.

Yes, Aspose.Words supports loading Word document formats (.DOC, .DOCX, .ODT etc) to PDF. Please see this article here for details. Likewise you can also set persmissions on the output PDF document. You can find further details in the API here.

Please correct me if I have misunderstood your query.


That’s it, thank you very much!