XML to PDF

Hello,

First, sorry for my english langage.

I test Aspose.Pdf (V 17.4)
i’m looking for export Xml to PDf with this exemple

<?xml version="1.0" encoding="utf-8" ?> 
  <Pdf xmlns="Aspose.Pdf"> 
   <Section ID="Section1"> 
        <Table ID="Table1" ColumnWidths="100 100"> 
         <DefaultCellBorder> 
                 <All LineWidth="0.1" /> 
         </DefaultCellBorder> 
         <Row> 
          <Cell> 
           <Text>
                   <Segment ID="Item">item 1</Segment>
           </Text> 
          </Cell> 
          <Cell> 
           <Text>
                   <Segment ID="Item">some content</Segment>
           </Text> 
          </Cell> 
         </Row> 
        </Table> 
   </Section> 
  </Pdf>

If i use Aspose.PDf.Generator in C# , it’s work but the code said it’s obsolete.
If i use Aspose.Pdf, it’s don’t work, the PDF Document have no page.

What I must use te generate document with XML document?

Thanks for your response.

Hello Damien,

Thanks for contacting support.

Yes, you are right about old legacy Aspose.Pdf.Generator approach has been obsolete and new Aspose.Pdf DOM approach was not recognizing the XML structure and creating empty PDF because it was based upon old XML Schema.

To generate PDF from XML using Aspose.Pdf DOM approach, you need to create XML based upon new approach. You can follow XML Schema which can be found in XML folder in Aspose.Pdf installation directory, to create XML with new structure.

However, I have modified your XML according to new model and created a PDF document by following code snippet without any issue. Please check attached output and input XML, for your reference.

Aspose.Pdf.Document doc = new Document();
doc.BindXml(dataDir + "XML_DOM.xml");
doc.Save(dataDir + "XMLtoPDF_out.pdf");

For more information, please refer to “Convert XML file to PDF” article in the API documentation. Moreover, please note that a new release of Aspose.Pdf for .NET has been launched recently with version 17.5 and it is always recommended to use latest version of the API. Please download Aspose.Pdf for .NET 17.5 from our website and in case of any further assistance, please feel free to contact us.

Best Regards,

Thanks four your answer.

It is possible to generate XML file from PDF file? Or else where can i found the worse of tag xml element i can use to write the XML file?


Hello Damien,


Thanks for contacting support.

You can convert a PDF file to XML format but the input file must be tagged PDF. For more information, please visit Convert PDF to XML