Create a Hello World PDF document through XML

Skip to end of metadata
Go to start of metadata
Aspose.Pdf provides the opportunity to convert an XML file into PDF document requiring that the input XML file must follow the Aspose.Pdf Schema
Implementation steps

Please follow these steps to convert an XML file into a PDF document:

  • Create an instance of Pdf class that represents a PDF document.
  • If you have purchased a license then you should also embed the code to use that license with the help of License class in Aspose.Pdf namespace.
  • Bind the input XML file to the instance of Pdf class by calling its BindXML method.
  • Save the bound XML with Pdf instance as a PDF document.
Code Snippets:
[XML]
<?xml version="1.0" encoding="utf-8" ?>
  <Pdf xmlns="Aspose.Pdf">
   <Section>
    <Text>
            <Segment>Hello World</Segment>
    </Text>
   </Section>
  </Pdf>
 
[JAVA]
//Instantiate License class and call its SetLicense method to use the license
com.aspose.pdf.License lic = new com.aspose.pdf.License();
lic.setLicense(new FileInputStream(new File("Aspose.Pdf.lic")));

//Bind XML into the document
Pdf pdf = Pdf.bindXML(new FileInputStream("../../../Example-XML/HelloWorld.XML"));

// Save the document
pdf.save(new FileOutputStream(new File("HelloWorld.pdf")));
 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.