Aspose.Pdf

Create a Hello World PDF document through API

Let's learn how to create a PDF document from scratch programmatically using the neat and simple API provided by Aspose.Pdf . To create PDF documents, we will have to add sections and paragraphs dynamically through the set of classes packaged in the Aspose.Pdf namespace.

 

Please follow these steps to create a PDF document using API:

 

 

Example:

 

[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");

 

//Add a section into the pdf document

Section sec1 = pdf1.Sections.Add();

 

//Add a text paragraph into the section

sec1.Paragraphs.Add(new Text("Hello World"));

 

//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")

 

'Add a section into the pdf document

Dim sec1 As Section = pdf1.Sections.Add()

 

'Add a text paragraph into the section

sec1.Paragraphs.Add(New Text("Hello World"))

 

'Save the document

pdf1.Save("HelloWorld.pdf")