RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Working with Aspose.Pdf for .NET

Take advantage of Aspose.Pdf for .NET, a set of PDF APIs for creating, reading and manipulating PDF documents in .NET seamlessly without the need of having Adobe Acrobat installed in your system.


Aspose.Pdf for .NET is a popular tool that can be used to create PDF documents. It helps you to create and manipulate PDF documents in .NET with ease. Most importantly, you can leverage Aspose.Pdf to manipulate existing PDF documents sans the need of having Adobe Acrobat installed in your system. This article provides an overview of Aspose.Pdf and how we can work with it in .NET applications.

Aspose.Pdf Features

Aspose.Pdf provides many interesting features. Some of the important features include the following:

  • Compression of PDF documents
  • Add or remove bookmarks
  • Support for graphs, fonts and hyperlinks
  • Convert pages to images
  • Print PDF documents
  • Import and Export PDF from data
  • Encrypt or decrypt PDF documents
  • Digitally sign PDF documents

Installing Aspose.Pdf

You can install Aspose.Pdf for .NET via NuGet Package Manager. To install Aspose.Pdf you can run the following command in the Package Manager Console.

PM> Install-Package Aspose.Pdf

Getting Started with Aspose.Pdf in Visual Studio

In this section, we will explore how we can work with Aspose.Pdf in .NET. We will learn how to create a PDF document using the Aspose.Pdf API.

Here's the list of the steps that you would need to follow to create a PDF document using the Aspose API for .NET.

  1. Open Visual Studio 2017 (I'm using Visual Studio 2017 in my system though you can use the earlier versions, i.e., Visual Studio 2015 or Visual Studio 2013 as well)
  2. Create a new C# console application project
  3. Save the project with a name
  4. Next, create an instance of the Pdf class (this class is available as part of the Aspose.Pdf.Generator) namespace
  5. Specify the license (if you have purchased a license) using the License class
  6. Add one or more sections to the Pdf object. Note that the Sections collection is used to hold one or more sections.
  7. Add a text paragraph to the section you just created
  8. Lastly, call the Save method on the Pdf instance to generate your PDF document

And that's all you need to do to create a PDF document using the Aspose.Pdf API.

Applying the License

Applying the license to the Aspose.Pdf is simple. All you need to do is create an instance of the Aspose.Pdf.License class, call the SetLicense method and pass the license file name as a parameter to the method.

The easiest way to apply the license to Aspose.Pdf component is by placing the license file inside the same directory where the Aspose.dll resides. This way you would not have to have the hassle of passing path while specifying the license file name to the SetLicense method. The following code snippet shows how you instantiate the License class, load the license from a license file and then make a call to the SetLicense method to apply the license.

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

Learn more about how to work with Aspose.Pdf from here.

If you would like to explore more on Aspose.Pdf or on any of the Aspose family of products, you can refer to their documentation.

The Complete Code Listing

The following code listing illustrates how you can create a new PDF document using the Aspose.Pdf API.

private static void Main(string[] args)
            //Create an instance of Pdf class
            var pdf = new Pdf.Generator.Pdf();
            //Specify the license to be used
            var license = new License();
            // Now, add a section into the pdf document
            var customSection = pdf.Sections.Add();
            // Next, add a text paragraph to the section just created
            customSection.Paragraphs.Add(new Text("This is a sample text"));
            // Save the document - this generates the document as well
            // The saved document is stored in the path mentioned

Note that the following namespaces should be included in your program for it to compile and work.



Aspose.Pdf for .NET is a popular PDF document creation component that you can use from within your .NET applications to create, edit and manage PDF documents without the need of having Acrobat installed in your system. This article presented a discussion on Aspose.Pdf, its incredible features and how you can get started using it in our .NET applications. Happy reading!

Joydip Kanjilal has over 10 years of industryexperience with C, C++, Java, C#, VB, VC++, ASP.Net, XML, Design Patterns,UML, etc. He currently works as a senior project leader in a reputablemultinational company in Hyderabad, India, and has contributed articles on.NET and related technologies to