1. Products
  2.   Aspose.PDF
  3.   Aspose.PDF FOSS for .NET

Aspose.PDF FOSS for .NET

Create and manipulate PDF documents from .NET — with annotations, form fields, text extraction, page management, encryption, and HTML/SVG/Markdown import. MIT-licensed.

Free MIT-Licensed .NET Library for PDF Creation and Manipulation

Aspose.PDF FOSS for .NET is a MIT-licensed library for creating and working with PDF documents in C# and .NET. The central entry point is the Document class, which supports construction from file path, byte array, stream, or password-protected sources, and exposes Open, Save, Merge, Encrypt, Decrypt, and Convert operations across the full PDF specification.

The library exposes 805 classes covering document structure via Document, Page, and PageCollection; rich annotations through AnnotationCollection (including AddTextAnnotation, AddLinkAnnotation, AddHighlightAnnotation, AddWatermarkAnnotation, and AddRedactAnnotation); interactive forms with Form, ButtonField, CheckboxField, RadioButtonField, and ChoiceField; text extraction and search via TextFragmentAbsorber and TextFragment; table detection with AbsorbedTable, AbsorbedRow, and AbsorbedCell; and document security via Document.Encrypt and Document.Decrypt. Format conversion supports HTML, SVG, and Markdown import alongside PDF export.

Install Aspose.PDF FOSS for .NET from NuGet: dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. The library is fully MIT-licensed with no runtime fees or usage restrictions. For enterprise features and support, see Aspose.PDF for .NET — Enterprise Product.

Document Structure and Page Management

  • Document API: Create new PDFs with Document() or open existing files via Document.Open(path), Document.Open(data), or Document.Open(stream).
  • Page management: Add, access, and reorder pages via PageCollection. Each Page exposes Width, Height, MediaBox, rotation, and Annotations.
  • Merge and split: Combine multiple files with Document.Merge(documents) or Document.MergeDocuments(files). Import specific pages with Document.ImportPage and Document.ImportPages.
  • Metadata: Read and write document metadata via DocumentInfo and Document.GetOrCreateMetadata().
  • Serialization: Persist documents with Document.Save(filename), Document.Save(stream, format), or Document.ToArray().

Common Document Processing Scenarios

  • PDF generation: Build documents programmatically by creating a Document instance and populating pages with content.
  • Document analysis: Open existing files for metadata inspection, page dimension measurement, or form field enumeration.
  • Page manipulation: Resize, rotate, or reorder pages using Document.ImportPage and the Page API.
  • Batch merging: Assemble report sections or invoice pages into a single PDF using Document.MergeDocuments.

Annotations and Form Fields

  • Rich annotation API: AnnotationCollection exposes methods for text, link, highlight, underline, strikeout, square, circle, line, ink, stamp, caret, redact, watermark, polygon, and polyline annotations.
  • Link actions: Add URI links with AddLinkAnnotation(rect, uri) or internal page-jump links with AddLinkAnnotation(rect, destinationPage, destRect).
  • Interactive forms: Access the document form via Document.Form to enumerate or create ButtonField, CheckboxField, RadioButtonField, and ChoiceField instances.
  • Annotation selection: Filter annotations by type across pages using AnnotationSelector with per-type Visit overloads.
  • Annotation flags: Control visibility, print, and lock behaviour via AnnotationFlags.

Document Review and Collaboration Scenarios

  • Markup review: Add highlight, underline, or free-text annotations for document review workflows.
  • Redaction: Permanently remove sensitive content regions using AddRedactAnnotation.
  • Watermarking: Stamp CONFIDENTIAL or APPROVED text onto pages with AddWatermarkAnnotation and AddStampAnnotation.
  • Interactive forms: Build fillable documents with radio buttons, checkboxes, and choice lists for data capture pipelines.

Text Extraction and Search

  • Text search: Use TextFragmentAbsorber to locate all text fragments on a page or across a document, with optional phrase matching.
  • Fragment properties: Each TextFragment exposes Text, Position, TextState (font, size, colour), and bounding rectangle.
  • Text state control: TextFragmentState provides access to Font, FontSize, ForegroundColor, BackgroundColor, and rendering mode.
  • Table detection: Identify and extract tabular content via AbsorbedTable, AbsorbedRow, and AbsorbedCell, each providing Rect and TextFragments.

Text and Data Extraction Scenarios

  • Content indexing: Extract all page text for full-text search pipelines.
  • Form data extraction: Read submitted field values for server-side processing.
  • Invoice parsing: Use AbsorbedTable to parse tabular row-and-column data from financial PDFs.
  • Redline comparison: Locate specific text fragments for precise position-based annotation or replacement.

Security and Encryption

  • AES and RC4 encryption: Encrypt documents with Document.Encrypt(userPassword, ownerPassword, permissions, algorithm) using Algorithm.AESx128, AESx256, or RC4x128.
  • Permission control: Restrict print, copy, and accessibility via DocumentPrivilege.
  • Password management: Change user and owner passwords with Document.ChangePasswords.
  • Decryption: Remove protection with Document.Decrypt().
  • Digital signatures: Access signature fields and PKCS#7 data through the Signature and Algorithm types.

Document Security Scenarios

  • Confidential distribution: Encrypt PDFs with per-recipient passwords before delivery.
  • Print-only contracts: Apply owner passwords with print-only DocumentPrivilege to prevent copying.
  • Compliance archiving: Strip encryption from internal archives after security review.
  • Signature verification: Inspect embedded digital signatures in received PDFs for authenticity checks.

Open a PDF, Add a Link Annotation, and Save

Open an existing PDF, attach a URI link annotation to page 1, and persist the result.

using Aspose.Pdf;

var data = System.IO.File.ReadAllBytes("input.pdf");
using var doc = Document.Open(data);
var page = doc.Pages[1];
var action = PdfAction.CreateUri("https://aspose.com");
page.Annotations.AddLinkAnnotation(
    new Rectangle(50, 700, 200, 720), action);
using var ms = new System.IO.MemoryStream();
doc.Save(ms);
System.IO.File.WriteAllBytes("output.pdf", ms.ToArray());

Add a Watermark Annotation

Stamp a watermark onto page 1 of an existing document and round-trip through serialization.

using Aspose.Pdf;

var input = System.IO.File.ReadAllBytes("report.pdf");
using var doc = Document.Open(input);
doc.Pages[1].Annotations.AddWatermarkAnnotation(
    new Rectangle(0, 0, 612, 792), "CONFIDENTIAL");
var saved = doc.ToArray();
System.IO.File.WriteAllBytes("watermarked.pdf", saved);

Extract Text Fragments from a Page

Use TextFragmentAbsorber to enumerate all text fragments on the first page.

using Aspose.Pdf;
using Aspose.Pdf.Text;

var data = System.IO.File.ReadAllBytes("document.pdf");
using var doc = Document.Open(data);
var absorber = new TextFragmentAbsorber();
absorber.Visit(doc.Pages[1]);
foreach (var fragment in absorber.TextFragments)
{
    Console.WriteLine(fragment.Text);
}

Frequently Asked Questions

What is the licensing model for Aspose.PDF FOSS for .NET?

Aspose.PDF FOSS for .NET is released under the MIT License, allowing free use in commercial products with no runtime fees. The source code is publicly available on GitHub.

How do I install Aspose.PDF FOSS for .NET?

Install from NuGet using dotnet add package Aspose.Pdf.Foss --version 0.1.0-alpha. The library targets .NET 8 and later with no native dependencies.

Which file formats does Aspose.PDF FOSS for .NET support?

The library reads and writes PDF and supports import of HTML, SVG, and Markdown. Raster export is also available — PDF pages can be rendered to BMP, JPEG, PNG, and TIFF.

How do I create a new PDF document?

Use Document.Create() to produce an empty document, then add pages and save with Document.Save(stream) or Document.ToArray().

Is a license key required to use Aspose.PDF FOSS for .NET?

No license key or activation step is required. The library runs fully unlicensed at no cost under the MIT License.

  

Support and Learning Resources