We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Pdf.Pdf class in Aspose.Pdf 4.1

I am using Aspose.Pdf version 4.1.

I am using the Aspose.Pdf.Pdf class:
Aspose.Pdf.Pdf pdfExport = new Aspose.Pdf.Pdf();

how do I add page numbers?

Hi Jonathan,

Thank you for considering Aspose.Pdf for .NET.

You can add Sections in your PDF object to create new Pages in your document. Please see the following sample code in this regard.

//Create pdf document

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();

//Add a section into the pdf document

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Add a text paragraph into the section

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

//Save the document


Also, you are using a very old version of Aspose.Pdf for .NET. We would recommend you to download and try the latest version of Aspose.Pdf for .NET v6.8 . This feature supports a lot of new features and functionalities. In the new version we have also merged Aspose.Pdf for .NET and Aspose.Pdf.Kit for .NET into a single product. You can use Aspose.Pdf.Generator.Pdf in the latest version instead of Aspose.Pdf.Pdf class. Please see the following documentation link regarding creating a new pdf document using Aspose.Pdf for .NET.

Create a Hello World PDF document through API

Please feel free to contact support in case you have any query or face any problem.

Thank You & Best Regards,

Hi Jonathan,

Thanks for using our products.

I have gone through your requirement and as per my understanding you need to add Page Number information while creating PDF document using Aspose.Pdf for .NET, whereas Nausherwan has shared information on how to add page during PDF generation process.

Please visit the following link for information on Image & Page Number in Header/Footer section. And as per comments shared by Nausherwan, you are using an older release of Aspose.Pdf for .NET so we recommend you to please update to latest release version of Aspose.Pdf for .NET 6.8.0. In case you still need to continue using older release version, please remove Generator namespace keyword from code snippet shared in above link. We are sorry for your inconvenience.

You may consider visiting the following link for information on Migration from Aspose.Pdf Pre-6.x