1. Products
  2.   PDF
  3.   .NET
  4.   PDF
 
  

Open Source .NET APIs for Managing PDFs

Free .NET API to to generate, edit, convert images to PDFs. Add Security, Table, Watermark, Text and Shapes to PDF Files.

A powerful open source standalone .NET library that allows software developers open, read, create, edit, and manipulate PDF documents without installing Adobe Acrobat component. The library is very stable and fully support large size PDF, 100+ Mb size documents are available in most case. The library requires.NET framework 4.0+ for smooth operation and can be integrated in desktop WinForms and ASP.NET application with ease.

The library has included support for adding watermarks to PDF documents and can easily customize the location, size and color of it. Developers can easily generate text watermark or inserting colorful image watermark as copyrighted There are numerous other features part of the library such as generate new PDF from the scratch, load and read existing PDF files, PDF security, encrypting or decrypting PDF documents, add images to PDFs, convert Images like JPEG, PNG and TIFF to PDF document, insert or delete new pages, inset text to PDF, add shapes inside PDF and many more.

PDF library has included great support for tables and provided various features for handling tables inside PDF documents It enables developers to generate table in PDF, generate table layout to place the content, insert rows and columns to tables and merge table cells with ease. It is also possible to add digital signature to PDF targeting page or particular section to keep it safe from external interference.

Previous Next

Getting Started with PDF

The best way to install PDF is via GitHub, please use the following command to install the API.

Install PDF from GitHub

 go get https://github.com/iditectweb/pdf.git 

Create & Edit PDF Files via .NET Library

The open source PDF library allows software developers to create new PDF documents inside their own C# .NET applications with ease. After the creation of documents you can modify it according your needs. You can insert new page, modify the existing pages, change page size, delete the unwanted section of a document and so on. It is also possible to load and read existing PDF document with ease.

Create New PDF File via .NET Library

 //Create new pdf document
PdfDocument document = new PdfDocument();

document.DocumentInfo.Author = "test author";
document.DocumentInfo.Description = "test description";
document.DocumentInfo.Title = "test title";

//Insert a new page
PdfPage page = document.Pages.AddPage();

//The default page size is A4
//Customize the page sie directly
page.Size = new Size(800, 1000);
//Or change the value by standard paper size
//page.Size = PaperTypeConverter.ToSize(PaperTypes.A4);


PdfFile pdfFile = new PdfFile();

//Save pdf to file using stream
using (FileStream fs = File.Create("CreateNew.pdf"))
{
    pdfFile.Export(document, fs);
} 

Convert Image to PDF via C# Library

The PDF library makes it easy for software programmers to create image from a PDF documents with just a couple of lines of .NET code. The library also provides support for a very valuable and demanding feature for converting multi-page TIFF to PDF document. It support to import a wide range of image files, such as JPGE, PNG, TIFF, BMP and GIF. To achieve it you need to create an empty PDF page as original image's size and draw image to page at position (0,0) point, so that the image will be rendered as a whole page. It is also possible to add this page to an existing PDF file or create a new one.

Export Image to PDF via C# .NET API

 PdfDocument document = new PdfDocument();
           
using (Stream imgStream = File.OpenRead("sample.jpg"))
{
    iDiTect.Pdf.Resources.ImageSource image = new iDiTect.Pdf.Resources.ImageSource(imgStream);

    //Create a new page with image's size
    PdfPage page = new PdfPage();
    page.Size = new Size(image.Width, image.Height);
    PageContentBuilder builder = new PageContentBuilder(page);

    //draw image to page at position (0,0)
    builder.DrawImage(image);

    document.Pages.Add(page);
}           

using (FileStream fs = File.OpenWrite("ConvertImageToPdf.pdf"))
{
    PdfFile pdfFile = new PdfFile();
    pdfFile.Export(document, fs);
}

How to Add Watermark to PDF via .NET

The open source PDF library allows computer programmers to add watermark to PDF in a very professional and easy way. It is possible to add text as well as image watermark to PDF documents with ease. It provides various features for handling watermark, such as change the text font name, font size, font style, font color text rotation, and location in the PDF page. It provides support to add colorful or transparent watermark with background.

How to Add Image Watermark to PDF via C#

 PdfFile pdfFile = new PdfFile();
PdfDocument document;

using (FileStream fs = File.OpenRead("sample.pdf"))
{
    //Read pdf document from stream
    document = pdfFile.Import(fs);
}
//Get first page of pdf
PdfPage page = document.Pages[0];
PageContentBuilder builder = new PageContentBuilder(page);

//Set watermark image position
builder.Position.Translate(100, 100);
using (Stream stream = File.OpenRead("watermark.png"))
{
    //Insert watermark image as original size
    builder.DrawImage(stream);
    //Insert watermark image in customized size
    //builder.DrawImage(stream, new Size(80, 80));
}

using (FileStream fs = File.OpenWrite("ImageWatermark.pdf"))
{
    pdfFile.Export(document, fs);
}

Add & Manage Tables in PDF via C# API

Tables are very important part of the PDF document that consists of rows and columns of cells and are used to hold important data for processing. The open source PDF library allows creating and modifying tables inside PDF documents using C #.NET. To create a standard table you need to define the color, border style used in table and add table title. After that you can add table header, add columns and rows with data value.

 English