Open Source .NET API for PDF Processing
Create, Manipulate, Convert & Process PDF Documents via Free C# .NET Library.
What is PDFsharp?
Open Source .NET library that can be used to create, render, merge, split, modify, print and extract text or meta-data of PDF files. The PDFsharp API supports creating PDF documents on the fly from any .NET language. It also supports importing data from various sources via XML files or direct interfaces. It supports numerous options for page layout, text formatting, and document design.
PDFsharp provides graphical implementation based either on GDI+ or WPF. The API makes developer’s job easy by providing features for using one source code for drawing on a PDF page as well as in a window or on the printer. It supports several important features for processing PDF files such as modifying PDF, merge or split PDFs, XPS to PDF conversion, PDF rendering, PDF data extraction, Font embedding and subsetting, Unicode support and many more.
At A Glance
An overview of PDFsharp features.
- Create PDF
- Modify PDF
- PDF merging
- XPS to PDF
- PDF rendering
- Manipulate PDF
- PDF annotations
- Data extraction
- Font embedding
- Encrypt PDF
- PDF form
- Unicode support
API mainly supports PDF format but can export PDF documents to a number of other formats.
PDFsharp can work with any .NET based programming language.
Getting Started with PDFsharp
PDFsharp is dual-licensed as AGPL/Commercial software. AGPL is a free/open-source software license.
It is highly recommended using NuGet to add PDFsharp to your project,
With Visual Studio you can install the NuGet Package Manager to easily access NuGet packages. It works with VS 2012 Express as well as with the community editions of VS 2013 and VS 2015. In Visual Studio go to "Tools" => "Extensions and Updates..." to install the NuGet Package Manager if you do not have it yet. The NuGet Package Manager will download the package for you, install it, add a reference to your project.
Generate & Modify PDF Documents via Free .NET API
Software developers can use PDFsharp API to create a new PDF document inside their own .NET applications. Once the document is created you can add an empty page as well insert graphics or text with ease. It also facilitates developers to modify the existing document according to their needs and save it with the name of their choice. Using the following steps you can generate & manipulate PDF documents in C#.
- Initialize PdfDocument
- Add Page
- Get an XGraphics object for drawing
- Create a font
- Add Text
- Save Document
Create PDF using C#
// Create a new PDF document PdfDocument pdfDocument = new PdfDocument(); // Create an empty page PdfPage pdfPage = pdfDocument.AddPage(); // Get an XGraphics object for drawing XGraphics xGraphics = XGraphics.FromPdfPage(pdfPage); // Create a font XFont xFont = new XFont("Verdana", 20, XFontStyle.BoldItalic); // Draw the text xGraphics.DrawString("File Format Developer Guide", xFont, XBrushes.Black, new XRect(0, 0, pdfPage.Width, pdfPage.Height), XStringFormats.Center); // Save the document... pdfDocument.Save("fileformat.pdf");
Create PDF Annotations
Annotations allow users to add custom content on PDF pages. PDF applications normally allow creating & modifying various types of annotations, such as text, lines, notes or shapes, etc. PDFsharp enables programmers to create various types of PDF annotations inside their own applications. The library supports the creation of text annotations, link and rubber stamp annotations.