The Document class is the heart of Aspose.PDF FOSS for .NET. It represents a complete PDF and provides access to every structure inside — pages, annotations, form fields, metadata, and embedded files.

Opening documents

Load a PDF from a file, a byte array, or a stream:

using var doc = Document.Open(File.ReadAllBytes("input.pdf"));
Console.WriteLine($"Pages: {doc.Pages.Count}");

Pages use 1-based indexing: doc.Pages[1] is the first page.

Creating from scratch

using var doc = new Document();
var page = doc.Pages.Add();
page.Paragraphs.Add(new TextFragment("Hello, PDF!"));
doc.Save("hello.pdf");

Tables, floating boxes, headers/footers, and graphs are all paragraph types that the layout engine places automatically.

Page manipulation

Set page geometry, rotation, and bounding boxes:

var page = doc.Pages[1];
page.SetMediaBox(new Rectangle(0, 0, 612, 792));
page.SetCropBox(new Rectangle(36, 36, 576, 756));
page.SetRotation(90);

Conversion

The library includes dedicated converters for several output formats:

ConverterOutput
PdfToHtmlConverterHTML
PdfToMarkdownConverterMarkdown
PdfToSvgConverterSVG
PdfToTextConverterPlain text

Rendering to raster images uses device classes (PngDevice, JpegDevice, TiffDevice, BmpDevice), each accepting a Resolution in DPI.

PDF/A compliance

Validate and convert documents to PDF/A-1B, PDF/A-2B, or PDF/A-3B:

var options = new PdfFormatConversionOptions(
    "log.xml",
    PdfFormat.PDF_A_1B,
    ConvertErrorAction.Delete);
doc.Convert(options);
doc.Save("pdfa.pdf");

Getting Started

dotnet add package Aspose.Pdf.Foss

For full API details, see the Document Management developer guide and the Conversion and Optimization guide.