Agentic, build-validated C# code examples for Aspose.PDF for .NET covering PDF creation, conversion, editing, annotations, forms, digital signatures, and text extraction. Every example compiles and runs successfully. Includes AGENTS.md guides optimized for AI coding agents.
This repository provides working code examples demonstrating Aspose.PDF for .NET capabilities. All examples are automatically generated, compiled, and validated using the Aspose.PDF Examples Generator.
| Metric | Value |
|---|---|
| Total examples | 2636 |
| Categories | 35 |
| Target framework | net10.0 |
| Aspose.PDF version | 26.7.0 |
| Last updated | 2026-07-21 |
This repository is structured for direct use by AI coding agents and LLM-powered tools:
AGENTS.md— root-level guide covering API surface, anti-patterns, and category tips- Per-category
AGENTS.md— targeted guidance inside each category folder index.json— machine-readable manifest of all 2636 examples with metadata- MCP-compatible — integrate with any MCP client (Claude Desktop, Cursor, Continue.dev)
| Category | Examples | Agent Guide |
|---|---|---|
accessibility-and-tagged-pdfs |
45 | AGENTS.md |
basic-operations |
57 | AGENTS.md |
compare-pdf |
29 | AGENTS.md |
conversion |
102 | AGENTS.md |
document |
117 | AGENTS.md |
facades-acroforms |
41 | AGENTS.md |
facades-annotations |
106 | AGENTS.md |
facades-bookmarks |
35 | AGENTS.md |
facades-convert-documents |
36 | AGENTS.md |
facades-documents |
101 | AGENTS.md |
facades-edit-document |
213 | AGENTS.md |
facades-extract-images-and-text |
83 | AGENTS.md |
facades-fill-forms |
35 | AGENTS.md |
facades-forms |
85 | AGENTS.md |
facades-metadata |
40 | AGENTS.md |
facades-pages |
117 | AGENTS.md |
facades-secure-documents |
38 | AGENTS.md |
facades-sign-documents |
35 | AGENTS.md |
facades-stamps |
48 | AGENTS.md |
facades-texts-and-images |
28 | AGENTS.md |
facades-xmp-metadata |
44 | AGENTS.md |
graphs-zugferd-operators |
82 | AGENTS.md |
pages |
100 | AGENTS.md |
parse-pdf |
63 | AGENTS.md |
securing-and-signing-pdf |
78 | AGENTS.md |
stamping |
50 | AGENTS.md |
uncategorized |
1 | AGENTS.md |
working-with-annotations |
156 | AGENTS.md |
working-with-attachments |
50 | AGENTS.md |
working-with-forms |
230 | AGENTS.md |
working-with-graphs |
77 | AGENTS.md |
working-with-images |
72 | AGENTS.md |
working-with-tables |
96 | AGENTS.md |
working-with-text |
73 | AGENTS.md |
working-with-xml |
73 | AGENTS.md |
Each category contains standalone .cs files that can be compiled and run independently.
Instantiate Aspose.Pdf.Document, add pages via doc.Pages.Add(), then doc.Save("output.pdf"). See the basic-operations and document category folders for working examples.
Load the source with new Document(path), then doc.Save(target, SaveFormat.DocX) (or Html / Xps / Tiff / etc.). Per-format examples live in the conversion and facades-convert-documents folders.
Use TextAbsorber (page-level) or TextFragmentAbsorber (search-based). Examples of both patterns live in working-with-text and facades-extract-images-and-text.
Use TextBoxField, CheckboxField (lowercase 'b'!), RadioButtonField, ButtonField -- all in the Aspose.Pdf.Forms namespace. Attach with doc.Form.Add(field, pageNum). See working-with-forms and facades-forms for complete examples.
Use PdfFileSignature (facades) or SignatureField + PkcsSignature (core API). Load a PFX certificate with new PdfFileSignature(document), then Sign(...). See securing-and-signing-pdf and facades-sign-documents for working end-to-end examples.
Call doc.Encrypt(userPass, ownerPass, DocumentPrivilege.ForbidAll, CryptoAlgorithm.AESx256, false) before Save, or new Document(path, password) to open an encrypted PDF. Examples in securing-and-signing-pdf and facades-secure-documents.
Create OutlineItemCollection (the type doubles as both node and child container -- there is no separate OutlineItem singular type in Aspose.PDF), set Title / Action / Open, then doc.Outlines.Add(item) or parent.Add(child). Examples in facades-bookmarks.
Annotation types live in Aspose.Pdf.Annotations (HighlightAnnotation, TextAnnotation, StampAnnotation, LinkAnnotation, SquareAnnotation, etc.). Attach via page.Annotations.Add(annotation). See working-with-annotations and facades-annotations.
Merge with PdfFileEditor.Concatenate(...). Split by page range with PdfFileEditor.SplitFromFirst / SplitToEnd / SplitFromFile. See facades-edit-document for both patterns.
Load the document, then doc.Convert(logStream, PdfFormat.PDF_A_1B, ConvertErrorAction.Delete) (or PDF_A_2B / PDF_A_3B). Save and the resulting file is PDF/A-compliant. See conversion for full samples.
Yes -- the repository ships an AGENTS.md at root and one per category, plus .well-known/agent.json, llm.txt, mcp.json, and a machine-readable index.json. Point your agent at the repo's raw URLs (or install the MCP server) and it can browse examples programmatically.
The library runs in evaluation mode without a license (with page-count and collection-size limits). For production use, apply a license via new License().SetLicense(path). Purchase / trial options: https://purchase.aspose.com/buy.
- .NET SDK (net10.0 or compatible version)
- Aspose.PDF for .NET NuGet package (26.7.0)
- Valid Aspose license (for production use)
Each example is a self-contained C# file. To run an example:
cd <CategoryFolder>
dotnet new console -o ExampleProject
cd ExampleProject
dotnet add package Aspose.PDF --version 26.7.0
# Copy the example .cs file as Program.cs
dotnet runusing (Document pdfDoc = new Document("input.pdf"))
{
// Work with document
}if (!File.Exists(inputPath))
{
Console.Error.WriteLine($"Error: File not found - {inputPath}");
return;
}
try
{
// Operations
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error: {ex.Message}");
}- One-based indexing: Aspose.PDF uses 1-based page indexing (
Pages[1]= first page) - Deterministic cleanup: All IDisposable objects wrapped in
usingblocks - Console output: Success/error messages written to Console.WriteLine/Console.Error
- Fully qualified types: Use
Aspose.Pdf.Drawing.Path(not barePath) to avoid ambiguity withSystem.IO.Path
Other Aspose products with agentic, build-validated example repositories:
| Product | Repository | Focus |
|---|---|---|
| Aspose.Words for .NET | aspose-words/agentic-net-examples | Word processing, DOCX, mail merge |
| Aspose.Cells for .NET | aspose-cells/agentic-net-examples | Spreadsheets, Excel, charts |
| Aspose.HTML for .NET | aspose-html/agentic-net-examples | HTML conversion, DOM editing |
| Aspose.Imaging for .NET | aspose-imaging/agentic-net-examples | Image conversion, manipulation |
| Aspose.Slides for .NET | aspose-slides/agentic-net-examples | Presentations, PowerPoint |
| Aspose.Email for .NET | aspose-email/agentic-net-examples | Email, calendars, messaging |
| Aspose.BarCode for .NET | aspose-barcode/agentic-net-examples | Barcode generation and recognition |
- Aspose.PDF for .NET Documentation — Guides, tutorials, and feature overviews
- API Reference — Complete class/method reference
- Release Notes — Version history and changelogs
- NuGet Package — Install via
dotnet add package Aspose.PDF - Direct Downloads — MSI/ZIP installers and DLLs
- Aspose.PDF Forum — Community Q&A and official support
- Aspose Blog - PDF — Tutorials, tips, and product updates
- GitHub Issues — Bug reports and feature requests
- Purchase — Commercial license options
- Temporary License — Full-feature evaluation license
All examples use Aspose.PDF for .NET and require a valid license for production use. See licensing options.
Maintained by an agentic example generation workflow | For AI-friendly guidance, see AGENTS.md | Last updated: 2026-07-21