agentleFS
aspose-pdfaspose-pdf/agentic-net-examples/working-with-xml/AGENTS.md

agentic-net-examples / working-with-xml

AGENTS.md2 starsChanged 4 months agoMITView on GitHub

C# examples for working-with-xml using Aspose.PDF for .NET

The file

We split this AGENTS.md into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After accessing or modifying elements, persist the document with {doc}.Save({output_pdf}).

    line 118
  2. Distinctive:

    Create a new {doc} (Aspose.Pdf.Document) instance, then call {doc}.BindXml({string_literal} xmlPath, {string_literal} xsltPath) to populate …

    line 119
  3. Distinctive:

    After binding, invoke {doc}.Save({string_literal} outputPath) to write the generated PDF to disk.

    line 120
  4. Distinctive:

    No modifications are performed on the retrieved objects.

    line 124

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS - working-with-xml

Working with XML in PDF using C# / .NET -- 72 verified, compile-tested examples for Aspose.PDF for .NET 26.8.0. Each .cs file is a standalone, build-validated console example, generated and runtime-checked by an AI agent before publishing.

Persona

You are a C# developer specializing in PDF processing using Aspose.PDF for .NET, working within the working-with-xml category. This folder contains standalone C# examples for working-with-xml operations. See the root agents.md for repository-wide conventions and boundaries.

Scope

  • This folder contains examples for working-with-xml.
  • Files are standalone .cs examples stored directly in this folder.

Required Namespaces

  • using Aspose.Pdf; (70/72 files) ← category-specific
  • using Aspose.Pdf.Text; (17/72 files)
  • using Aspose.Pdf.Annotations; (7/72 files)
  • using Aspose.Pdf.Devices; (4/72 files)
  • using Aspose.Pdf.Forms; (4/72 files)
  • using Aspose.Pdf.Optimization; (4/72 files)
  • using Aspose.Pdf.Drawing; (2/72 files)
  • using Aspose.Pdf.Comparison; (1/72 files)
  • using Aspose.Pdf.Facades; (1/72 files)
  • using Aspose.Pdf.LogicalStructure; (1/72 files)
  • using Aspose.Pdf.Tagged; (1/72 files)
  • using System; (72/72 files)
  • using System.IO; (70/72 files)
  • using System.Xml.Linq; (15/72 files)
  • using System.Xml; (10/72 files)
  • using System.Collections.Generic; (4/72 files)
  • using System.Data; (2/72 files)
  • using System.Linq; (2/72 files)
  • using System.Text; (2/72 files)
  • using Microsoft.Extensions.DependencyInjection; (1/72 files)
  • using System.Diagnostics; (1/72 files)
  • using System.Globalization; (1/72 files)
  • using System.Text.Json; (1/72 files)
  • using System.Threading; (1/72 files)
  • using System.Threading.Tasks; (1/72 files)

Common Code Pattern

Most files in this category load documents with XmlLoadOptions:

XmlLoadOptions options = new XmlLoadOptions();
using (Document doc = new Document("input.pdf", options))
{
    // ... operations ...
    doc.Save("output.pdf");
}

Files in this folder

FileTitleKey APIsDescription
add-background-images-to-pdf-pagesAdd Background Images to PDF Pages from XMLDocument, Page, BackgroundArtifactDemonstrates loading an XML file that maps page numbers to image files and applying those images ...
add-custom-page-borders-to-pdfAdd Custom Page Borders to PDF Using GraphsDocument, Page, GraphShows how to draw a rectangular border on each page of a PDF by creating a Graph container, addin...
add-header-footer-to-pdf-using-xml-templatesAdd Header and Footer to PDF Using XML TemplatesDocument, Page, HeaderFooterDemonstrates loading header and footer text from XML files, inserting page numbers, and applying ...
add-javascript-actions-to-pdf-from-xmlAdd JavaScript Actions to PDF from XMLDocument, XmlLoadOptions, TextBoxFieldDemonstrates loading an XML file into a PDF, adding a document‑level JavaScript alert, creating a...
add-page-transitions-to-pdf-from-xmlAdd Page Transition Effects to PDF Generated from XMLDocument, XmlLoadOptions, PageLoads an XML file into a PDF document using Aspose.Pdf, attaches JavaScript actions to each page ...
apply-css-from-xml-to-pdfApply CSS from XML/XSL to Generate Styled PDFDocument, XmlLoadOptions, SaveDemonstrates how to load an XML document with an XSL stylesheet that references external CSS file...
apply-custom-font-to-xml-elementsApply Custom Font to Specific XML Elements in PDFDocument, XmlLoadOptions, OpenFontDemonstrates loading an XML file into a PDF, extracting text fragments, and applying a custom Tru...
apply-section-specific-page-marginsApply Section-Specific Page Margins Using XMLDocument, MarginInfo, MarginShows how to load margin definitions from an XML file and apply different margins to defined page...
apply-xml-color-to-pdf-page-backgroundSet PDF Page Background Color from XML ValueDocument, Save, ParseLoads a PDF, parses an XML color string (hex or rgb) into an Aspose.Pdf.Color, and applies that c...
batch-convert-xml-to-pdfBatch Convert XML Files to PDFDocument, XmlLoadOptions, SaveShows how to load all XML files in a folder and convert each one to a PDF document using Aspose.P...
batch-xml-to-pdf-conversion-profilingBatch XML to PDF Conversion with Performance ProfilingDocument, XmlLoadOptions, SaveDemonstrates how to convert multiple XML files to PDF using Aspose.Pdf while measuring load, save...
compress-pdf-streams-using-aspose-pdfCompress PDF Streams Using Aspose.Pdf OptimizationDocument, OptimizationOptions, OptimizeResourcesShows how to load a PDF (e.g., generated from XML), apply resource optimization to compress strea...
compress-pdf-text-objects-from-xmlCompress PDF Text Objects from XMLDocument, XmlLoadOptions, OptimizationOptionsDemonstrates converting an XML file to a PDF with Aspose.Pdf and applying stream compression to t...
compress-pdf-text-streams-flate-xmlCompress PDF Text Streams with Flate via XML ConversionDocument, XmlSaveOptions, XmlLoadOptionsThe example converts a PDF to XML, reloads it, applies Flate compression to all objects (includin...
concurrent-xml-to-pdf-conversionConcurrent XML to PDF Conversion with Aspose.PdfDocument, XmlLoadOptions, SaveDemonstrates how to safely convert multiple XML files to PDF in parallel using Aspose.Pdf's XmlLo...
convert-pdf-pages-to-png-thumbnailsConvert PDF Pages to High-Resolution PNG ThumbnailsDocument, Resolution, PngDeviceDemonstrates how to load a PDF with Aspose.Pdf, set a high DPI resolution, and render each page a...
convert-styled-html-to-pdf-with-custom-colorsConvert Styled HTML to PDF with Custom ColorsDocument, HtmlLoadOptions, SaveDemonstrates how to embed inline CSS in an HTML file and use Aspose.Pdf to convert it into a PDF ...
convert-xml-to-pdf-with-loggingConvert XML Files to PDF with Detailed LoggingDocument, XmlLoadOptions, PdfExceptionReads XML files from a directory, converts each to a PDF using Aspose.Pdf, and records detailed p...
convert-xml-to-pdf-with-xsltConvert XML to PDF with XSLT TransformationXmlLoadOptions, ctor, DocumentDemonstrates loading an XML file, applying an XSLT stylesheet during loading with Aspose.Pdf, and...
convert-xml-to-pdfConvert XML to PDF using Aspose.PdfDocument, XmlLoadOptions, SaveDemonstrates loading an XML file and converting it to a PDF with Aspose.Pdf's default XSLT transf...
convert-xml-to-pdfa-2b-and-validateConvert XML to PDF/A‑2b and Validate ComplianceDocument, XmlLoadOptions, PdfFormatShows how to load an XML file, convert it to PDF/A‑2b format, save the PDF, and validate the outp...
create-barcodes-pdf-from-xmlCreate Barcodes in PDF from XML FieldsDocument, XmlLoadOptions, PageShows how to load an XML file as a PDF, read barcode field definitions, generate Code128 barcodes...
create-hierarchical-pdf-outline-from-xmlCreate Hierarchical PDF Outline from XMLDocument, OutlineItemCollection, XYZExplicitDestinationShows how to load an XML file and generate a PDF with a nested bookmark outline that mirrors the ...
create-pdf-from-xsl-fo-memory-streamCreate PDF from XSL‑FO Using a MemoryStreamDocument, XslFoLoadOptions, SaveDemonstrates loading XSL‑FO XML from a MemoryStream and generating a PDF document with default se...
create-pdf-outline-from-xmlCreate PDF Outline Hierarchy from XML NestingDocument, XmlLoadOptions, OutlineItemCollectionDemonstrates loading an XML file with Aspose.Pdf, then generating a PDF outline whose hierarchy m...
create-pdf-outlines-from-xml-section-titlesCreate PDF Outlines from XML Section TitlesDocument, Page, TextFragmentReads section titles from an XML file, generates a PDF page for each title, and adds outline (boo...
create-pdf-toc-from-xmlCreate PDF Table of Contents from XML HeadingsDocument, ITaggedContent, TOCElementShows how to build a hierarchical Table of Contents in a PDF by reading heading data from an XML ...
create-pdf-xfa-form-from-xmlCreate PDF XFA Form Fields from XML and Set Default ValuesDocument, Form, AssignXfaShows how to load or create a PDF, assign an XFA form definition from an XML file, set default fi...
create-png-thumbnail-from-xmlCreate PNG Thumbnail of First PDF Page from XMLDocument, XmlLoadOptions, PageThe example loads an XML file, converts it to a PDF using Aspose.Pdf, and generates a PNG thumbna...
downsample-images-from-xmlDownsample Images from XML to PDF using Aspose.PdfDocument, BindXml, OptimizationOptionsShows how to load an XML file, convert it to a PDF, and down‑sample high‑resolution images by con...
...and 42 more files

Category Statistics

  • Total examples: 72

Category-Specific Tips

Key API Surface

  • Aspose.Pdf.Document
  • Aspose.Pdf.Document.BindXml(string)
  • Aspose.Pdf.Document.BindXml(string, string)
  • Aspose.Pdf.Document.GetObjectById(string)
  • Aspose.Pdf.Document.Save(string)
  • Aspose.Pdf.Page
  • Aspose.Pdf.Text.TextSegment

Rules

  • To create a PDF from an XML layout, call {doc}.BindXml({xml_path}).
  • To obtain a PDF element defined in the XML, use {doc}.GetObjectById({object_id}) and cast the result to the expected type (e.g., {page}, {text_fragment}).
  • After accessing or modifying elements, persist the document with {doc}.Save({output_pdf}).
  • Create a new {doc} (Aspose.Pdf.Document) instance, then call {doc}.BindXml({string_literal} xmlPath, {string_literal} xsltPath) to populate the document from XML/XSLT.
  • After binding, invoke {doc}.Save({string_literal} outputPath) to write the generated PDF to disk.

Warnings

  • The example casts the result of GetObjectById without null checks; IDs must exist in the XML.
  • No modifications are performed on the retrieved objects; further processing may be required depending on the scenario.
  • BindXml expects valid file paths to existing XML and XSLT files; missing files will raise an exception.
  • The example creates an empty document before binding; binding after adding pages may produce unexpected layout.
  • BindXml requires that the provided XML and XSLT files are well‑formed and compatible; otherwise an exception will be thrown.

General Tips

  • See parent AGENTS.md for:
    • Boundaries -- Always / Ask First / Never rules for all examples
    • Common Mistakes -- verified anti-patterns that cause build failures
    • Domain Knowledge -- cross-cutting API-specific gotchas
    • Testing Guide -- build and run verification steps
  • Review code examples in this folder for working-with-xml patterns
<!-- AUTOGENERATED:START -->

Updated: 2026-08-20 | Run: 20260820_001147_12d7b3

<!-- AUTOGENERATED:END -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.