PDF to XML and read


Hi ,

I’m using aspose pdf.net to process a PDF. I would like t convert the PDF to XML and read the XML for further processing. Is it possible for me to do that? Any help is greatly appreciated.




We have already shared required code snippet in response to your previous inquiry. However, would you please explain a bit more about your requirements to generate PDF from XML. Do you want to use Aspose.PDF for .NET to convert XML into PDF? Would you kindly share some sample file(s) with expected output. We will further proceed to assist you accordingly.


Hi Asad,

Thanks for getting back so quickly. My requirement is that I have a PDF and I would like to convert the PDF in to XML and read few information out of XML. But i’ll not have write permission to save the xml file in the location. I would like to rather read the XML and keep it in memory stream and process the same from there. The sample given in my previous inquiry was to save the file as XML. Is it possible to share the code to save it in stream and re-use it.



Please use following code snippet to save results in a MemoryStream so that they can be re-used:

MemoryStream ms = new MemoryStream();
Document doc = new Document(dataDir + "SamplePDF (2).pdf");
doc.Save(ms, SaveFormat.MobiXml);


Thanks Asad. Looks like we are using the old version of Aspose and the MobiXml option is not available in this version.



You may please try using Aspose.PDF for .NET 19.9 as it is always recommended to use latest version.


Thanks Asad. I updated the version but got the following error when tried the code.

System.ArgumentException “Save a document to a xml stream is not supported. Please save to a file instead.”



Would you kindly share your source PDF document with us. We will test the scenario in our environment and address it accordingly.