1. Products
  2.   Editor
  3.   .NET
  4.   QuestPDF
 
  

Open Source .NET API for working with PDF documents

Create, update, merge and process PDF documents from within .NET applications.

What is QuestPDF API for .NET?

QuestPDF is a popular .NET library designed for generating high-quality PDF documents with ease. It offers a modern, intuitive API that allows you to create complex PDF layouts programmatically, making it suitable for applications that require automated PDF report generation, invoices, or document creation. QuestPDF is built around a flexible layout engine that supports a wide range of design features such as text formatting, tables, images, and even charts. With its fluent, easy-to-understand syntax, developers can quickly define the structure of PDF documents while maintaining full control over styling and formatting. The library is also optimized for performance, ensuring fast PDF rendering even for large documents.

QuestPDF for .NET API - Key Features

Following are some of the main features of QuestPDF:

  • Fluent and intuitive API for creating PDF documents programmatically.
  • Supports complex layouts, including grids, tables, and flexible positioning.
  • Comprehensive text formatting options for headers, paragraphs, and more.
  • Ability to add images, charts, and other visual elements to documents.
  • Dynamic content generation based on business rules and data input.
  • High-performance rendering optimized for large documents.
  • Built-in support for page headers, footers, and page numbers.
  • Automatic content overflow handling across multiple pages.
  • Open-source and well-documented with active community support.
  • Seamless integration with .NET applications, supporting .NET Core and .NET Framework.
These features highlight the capabilities and benefits of using QuestPDF API for .NET in PDF document creation and manipulation.
GitHub

GitHub Stats

Name:
Language:
Stars:
Forks:
License:
Repository was last updated at

Getting Started with QuestPDF for .NET API

You can download the QuestPDF library from GitHub or nuget.

Installation

Installing QuestPDF API for .NET is simple and can be done from nugget as shown below:

Installing QuestPDF API for .NET


 Install-Package QuestPDF

Code Examples for QuestPDF API for .NET

To help you better understand the capabilities of the QuestPDF API, lets have a look at some .NET code examples. These examples will demonstrate how to create various PDF elements, manage layouts, and apply formatting using QuestPDF’s intuitive, fluent API. By following these examples, you'll be able to effectively integrate PDF generation into your .NET applications.

How to Create a blank PDF file using QuestPDF API for .NET?

In order to create a PDF document using the QuestPDF API for .NET, the following steps can help.

  • Import the required QuestPDF namespaces into your file.
  • Create a new C# class or method to define the PDF content.
  • Use the Document.Create() method to start the PDF document creation process.
  • Implement the Compose() method to define the structure and layout of the PDF.
  • Add a blank page using the Page() method without any content inside.
  • Call the GeneratePdf() method to generate and save the PDF to the desired location.
  • Run the application to create and save the blank PDF file.

How to add Image to a PDF using QuestPDF API?

You can create a PDF document using QuestPDF for .NET and insert image into it from your .NET application. You can use the following steps to create a PDF document with image.

  • Create a new PDF document: This initializes an empty PDF document.
  • Add a page: Adds a blank page to the document.
  • Add an image using the Image() method.
  • Adjust the width of the page using the FitWidth option to ensure that the image fits the width of the page.
  • Saves the PDF with the image.

How to Add a Watermark to a PDF Page in .NET?

To add a watermark to a PDF page using the QuestPDF API for .NET API, you can use the following steps.

  • Install the QuestPDF library via NuGet Package Manager in your .NET project.
  • Import the necessary QuestPDF namespaces into your file.
  • Create a new C# class or method to define the PDF content.
  • Use the Document.Create() method to start the PDF creation process.
  • Define the page layout using the Page() method, setting page size and margin.
  • Use the Layer() method to create separate layers for main content and watermark.
  • Add main content elements using methods like Text() or Image() in the first layer.
  • Add a watermark element (e.g., text or image) in the second layer, setting properties like Opacity(), FontSize(), and Rotate() to style the watermark.
  • Generate the PDF using the GeneratePdf() method and save it to a file.
  • Run the application to create and save the PDF with a watermark.

Conclusion

QuestPDF is a versatile and efficient library for .NET developers seeking to create dynamic, high-quality PDF documents programmatically. Its fluent API design, extensive layout options, and support for a wide range of content make it a powerful tool for generating professional PDFs for various use cases, from reports to invoices. Whether you need to handle complex layouts, add images, or overlay watermarks, QuestPDF offers the flexibility and performance to get the job done seamlessly. By integrating QuestPDF into your projects, you can automate PDF creation with ease while maintaining full control over document design.

Similar Products

 English