Aspose.Pdf

Create a Hello World PDF document through XML

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 .

 

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

 

 

Code Snippet

 

[Input XML File]

 

<?xml version="1.0" encoding="utf-8" ?>

  <Pdf xmlns="Aspose.Pdf">

   <Section>

    <Text>

            <Segment>Hello World</Segment>

    </Text>

   </Section>

  </Pdf>

 

[C#]

 

//Create pdf document

Pdf pdf1 = new Pdf();

 

//Instantiate License class and call its SetLicense method to use the license

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("Aspose.Pdf.lic");

 

//Bind XML into the document

pdf1.BindXML("../../../Example-XML/HelloWorld.XML",null);

 

//Save the document

pdf1.Save("HelloWorld.pdf");

 

[VB.NET]

 

'Create pdf document

Dim pdf1 As Pdf = New Pdf()

 

'Instantiate License class and call its SetLicense method to use the license

Dim license As license = New license

License.SetLicense("Aspose.Pdf.lic")

 

'Bind XML into the document

pdf1.BindXML("../../Example-XML/HelloWorld.XML", Nothing)

 

'Save the document

pdf1.Save("HelloWorld.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")));