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
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository36 other files it gives its agents.
- accessibility-and-tagged-pdfsAGENTS.md
- aspose-pdf-examplesAGENTS.md
- basic-operationsAGENTS.md
- compare-pdfAGENTS.md
- conversionAGENTS.md
- documentAGENTS.md
- facades-acroformsAGENTS.md
- facades-annotationsAGENTS.md
- facades-bookmarksAGENTS.md
- facades-convert-documentsAGENTS.md
- facades-documentsAGENTS.md
- facades-edit-documentAGENTS.md
- facades-extract-images-and-textAGENTS.md
- facades-fill-formsAGENTS.md
- facades-formsAGENTS.md
- facades-metadataAGENTS.md
- facades-pagesAGENTS.md
- facades-secure-documentsAGENTS.md
- facades-sign-documentsAGENTS.md
- facades-stampsAGENTS.md
- facades-texts-and-imagesAGENTS.md
- facades-xmp-metadataAGENTS.md
- graphs-zugferd-operatorsAGENTS.md
- pagesAGENTS.md
- parse-pdfAGENTS.md
- securing-and-signing-pdfAGENTS.md
- stampingAGENTS.md
- uncategorizedAGENTS.md
- working-with-annotationsAGENTS.md
- working-with-attachmentsAGENTS.md
- working-with-formsAGENTS.md
- working-with-graphsAGENTS.md
- working-with-imagesAGENTS.md
- working-with-tablesAGENTS.md
- working-with-textAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
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
- Distinctive: line 118
After accessing or modifying elements, persist the document with {doc}.Save({output_pdf}).
- Distinctive: line 119
Create a new {doc} (Aspose.Pdf.Document) instance, then call {doc}.BindXml({string_literal} xmlPath, {string_literal} xsltPath) to populate …
- Distinctive: line 120
After binding, invoke {doc}.Save({string_literal} outputPath) to write the generated PDF to disk.
- Distinctive: line 124
No modifications are performed on the retrieved objects.
≈ “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.
Files
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
.csfile 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
.csexamples stored directly in this folder.
Required Namespaces
using Aspose.Pdf;(70/72 files) ← category-specificusing 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
| File | Title | Key APIs | Description |
| add-background-images-to-pdf-pages | Add Background Images to PDF Pages from XML | Document, Page, BackgroundArtifact | Demonstrates loading an XML file that maps page numbers to image files and applying those images ... |
| add-custom-page-borders-to-pdf | Add Custom Page Borders to PDF Using Graphs | Document, Page, Graph | Shows 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-templates | Add Header and Footer to PDF Using XML Templates | Document, Page, HeaderFooter | Demonstrates loading header and footer text from XML files, inserting page numbers, and applying ... |
| add-javascript-actions-to-pdf-from-xml | Add JavaScript Actions to PDF from XML | Document, XmlLoadOptions, TextBoxField | Demonstrates loading an XML file into a PDF, adding a document‑level JavaScript alert, creating a... |
| add-page-transitions-to-pdf-from-xml | Add Page Transition Effects to PDF Generated from XML | Document, XmlLoadOptions, Page | Loads an XML file into a PDF document using Aspose.Pdf, attaches JavaScript actions to each page ... |
| apply-css-from-xml-to-pdf | Apply CSS from XML/XSL to Generate Styled PDF | Document, XmlLoadOptions, Save | Demonstrates how to load an XML document with an XSL stylesheet that references external CSS file... |
| apply-custom-font-to-xml-elements | Apply Custom Font to Specific XML Elements in PDF | Document, XmlLoadOptions, OpenFont | Demonstrates loading an XML file into a PDF, extracting text fragments, and applying a custom Tru... |
| apply-section-specific-page-margins | Apply Section-Specific Page Margins Using XML | Document, MarginInfo, Margin | Shows how to load margin definitions from an XML file and apply different margins to defined page... |
| apply-xml-color-to-pdf-page-background | Set PDF Page Background Color from XML Value | Document, Save, Parse | Loads a PDF, parses an XML color string (hex or rgb) into an Aspose.Pdf.Color, and applies that c... |
| batch-convert-xml-to-pdf | Batch Convert XML Files to PDF | Document, XmlLoadOptions, Save | Shows 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-profiling | Batch XML to PDF Conversion with Performance Profiling | Document, XmlLoadOptions, Save | Demonstrates how to convert multiple XML files to PDF using Aspose.Pdf while measuring load, save... |
| compress-pdf-streams-using-aspose-pdf | Compress PDF Streams Using Aspose.Pdf Optimization | Document, OptimizationOptions, OptimizeResources | Shows how to load a PDF (e.g., generated from XML), apply resource optimization to compress strea... |
| compress-pdf-text-objects-from-xml | Compress PDF Text Objects from XML | Document, XmlLoadOptions, OptimizationOptions | Demonstrates converting an XML file to a PDF with Aspose.Pdf and applying stream compression to t... |
| compress-pdf-text-streams-flate-xml | Compress PDF Text Streams with Flate via XML Conversion | Document, XmlSaveOptions, XmlLoadOptions | The example converts a PDF to XML, reloads it, applies Flate compression to all objects (includin... |
| concurrent-xml-to-pdf-conversion | Concurrent XML to PDF Conversion with Aspose.Pdf | Document, XmlLoadOptions, Save | Demonstrates how to safely convert multiple XML files to PDF in parallel using Aspose.Pdf's XmlLo... |
| convert-pdf-pages-to-png-thumbnails | Convert PDF Pages to High-Resolution PNG Thumbnails | Document, Resolution, PngDevice | Demonstrates 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-colors | Convert Styled HTML to PDF with Custom Colors | Document, HtmlLoadOptions, Save | Demonstrates how to embed inline CSS in an HTML file and use Aspose.Pdf to convert it into a PDF ... |
| convert-xml-to-pdf-with-logging | Convert XML Files to PDF with Detailed Logging | Document, XmlLoadOptions, PdfException | Reads XML files from a directory, converts each to a PDF using Aspose.Pdf, and records detailed p... |
| convert-xml-to-pdf-with-xslt | Convert XML to PDF with XSLT Transformation | XmlLoadOptions, ctor, Document | Demonstrates loading an XML file, applying an XSLT stylesheet during loading with Aspose.Pdf, and... |
| convert-xml-to-pdf | Convert XML to PDF using Aspose.Pdf | Document, XmlLoadOptions, Save | Demonstrates loading an XML file and converting it to a PDF with Aspose.Pdf's default XSLT transf... |
| convert-xml-to-pdfa-2b-and-validate | Convert XML to PDF/A‑2b and Validate Compliance | Document, XmlLoadOptions, PdfFormat | Shows how to load an XML file, convert it to PDF/A‑2b format, save the PDF, and validate the outp... |
| create-barcodes-pdf-from-xml | Create Barcodes in PDF from XML Fields | Document, XmlLoadOptions, Page | Shows how to load an XML file as a PDF, read barcode field definitions, generate Code128 barcodes... |
| create-hierarchical-pdf-outline-from-xml | Create Hierarchical PDF Outline from XML | Document, OutlineItemCollection, XYZExplicitDestination | Shows how to load an XML file and generate a PDF with a nested bookmark outline that mirrors the ... |
| create-pdf-from-xsl-fo-memory-stream | Create PDF from XSL‑FO Using a MemoryStream | Document, XslFoLoadOptions, Save | Demonstrates loading XSL‑FO XML from a MemoryStream and generating a PDF document with default se... |
| create-pdf-outline-from-xml | Create PDF Outline Hierarchy from XML Nesting | Document, XmlLoadOptions, OutlineItemCollection | Demonstrates loading an XML file with Aspose.Pdf, then generating a PDF outline whose hierarchy m... |
| create-pdf-outlines-from-xml-section-titles | Create PDF Outlines from XML Section Titles | Document, Page, TextFragment | Reads section titles from an XML file, generates a PDF page for each title, and adds outline (boo... |
| create-pdf-toc-from-xml | Create PDF Table of Contents from XML Headings | Document, ITaggedContent, TOCElement | Shows how to build a hierarchical Table of Contents in a PDF by reading heading data from an XML ... |
| create-pdf-xfa-form-from-xml | Create PDF XFA Form Fields from XML and Set Default Values | Document, Form, AssignXfa | Shows how to load or create a PDF, assign an XFA form definition from an XML file, set default fi... |
| create-png-thumbnail-from-xml | Create PNG Thumbnail of First PDF Page from XML | Document, XmlLoadOptions, Page | The example loads an XML file, converts it to a PDF using Aspose.Pdf, and generates a PNG thumbna... |
| downsample-images-from-xml | Downsample Images from XML to PDF using Aspose.Pdf | Document, BindXml, OptimizationOptions | Shows 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.DocumentAspose.Pdf.Document.BindXml(string)Aspose.Pdf.Document.BindXml(string, string)Aspose.Pdf.Document.GetObjectById(string)Aspose.Pdf.Document.Save(string)Aspose.Pdf.PageAspose.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 -->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
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.

