| Aspose.Pdf for .NET provides the opportunity to convert an XML file into PDF document requiring that the input XML file must follow the Aspose.Pdf for .NET Schema. |
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
XML
<?xml version="1.0" encoding="utf-8" ?> <Pdf xmlns="Aspose.Pdf"> <Section> <Text> <Segment>Hello World</Segment> </Text> </Section> </Pdf>
C#
//Create pdf document Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.GeneratorPdf(); //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 Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.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")
