agentic-net-examples / extraction
AGENTS.md4 starsChanged 3 months agoMITView on GitHub
Verified C# examples for extraction scenarios in Aspose.Words 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 repository29 other files it gives its agents.
- aspose-words-examplesAGENTS.md
- barcode-imageAGENTS.md
- chartsAGENTS.md
- commentsAGENTS.md
- comparisonAGENTS.md
- content-controlAGENTS.md
- conversionAGENTS.md
- find-and-replaceAGENTS.md
- fontsAGENTS.md
- form-fieldsAGENTS.md
- hyphenationAGENTS.md
- imagesAGENTS.md
- join-documentsAGENTS.md
- linq-reportingAGENTS.md
- listsAGENTS.md
- mail-mergeAGENTS.md
- officemathAGENTS.md
- ole-objectsAGENTS.md
- paragraphsAGENTS.md
- programming-with-documentsAGENTS.md
- rangeAGENTS.md
- renderingAGENTS.md
- security-and-protectionAGENTS.md
- shapesAGENTS.md
- split-documentAGENTS.md
- track-changesAGENTS.md
- vba-macrosAGENTS.md
- watermarkAGENTS.md
- working-with-tableAGENTS.md
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 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.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use native Aspose.Words extraction APIs directly.
- Very specific: line 20
Use Aspose.Words.Tables for Table, Row, and Cell when structured extraction is required.
- Very specific: line 21
Use Newtonsoft.Json for JSON serialization tasks and Aspose.Drawing instead of System.Drawing when drawing-related types are needed.
- Distinctive: line 32
Use the simplest workflow that satisfies the task.
- Distinctive: line 255
When replacing a file, prefer the latest verified publish-ready version rather than a merely compiling draft.
- Distinctive: line 256
Keep examples standalone, bootstrap missing inputs locally, and prefer documented Aspose APIs over speculative shortcuts.
≈ “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.md - Extraction
Purpose
This folder is a live, curated example set for Extraction scenarios. Treat every .cs file as a standalone console application. The goal is correct, warning-free examples that use documented Aspose APIs and match the original task intent.
Non-negotiable conventions
- Use native Aspose.Words extraction APIs directly.
- Bootstrap local source documents, files, images, streams, or folders whenever the task implies an existing source.
- Enumerate actual document nodes and validate their types before extracting content.
- Use
Aspose.Words.TablesforTable,Row, andCellwhen structured extraction is required. - Use
Newtonsoft.Jsonfor JSON serialization tasks andAspose.Drawinginstead ofSystem.Drawingwhen drawing-related types are needed. - Guard maybe-null values to avoid nullable-reference warnings such as
CS8600,CS8602, andCS8604.
Recommended workflow selection
- Text Range Extraction workflow: 11 examples
- Targeted Node Extraction workflow: 9 examples
- Table Structured Extraction workflow: 6 examples
- Input Bootstrap workflow: 1 examples
- Image Shape Extraction workflow: 3 examples
Use the simplest workflow that satisfies the task.
Validation priorities
- The code must compile and run without manual input.
- API usage must be supported by the configured package versions.
- Exported outputs must actually be written by the example.
- Validation scenarios must inspect only the behavior requested by the task.
- Examples that depend on files, folders, streams, images, or data should bootstrap those inputs locally during the example run.
File-to-task reference
load-a-docx-file-extract-content-between-two-paragraphs-and-save-the-result-as-a-new-docx.cs- Task: Load a DOCX file, extract content between two paragraphs, and save the result as a new DOCX.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
load-a-docm-file-extract-content-between-a-macro-enabled-field-and-a-paragraph-and-save-as.cs- Task: Load a DOCM file, extract content between a macro-enabled field and a paragraph, and save as DOCX.
- Workflow: targeted-node-extraction
- Outputs: docx, doc
- Selected engine: mcp
identify-a-start-run-node-and-an-end-bookmark-node-then-extract-the-intervening-nodes-into.cs- Task: Identify a start run node and an end bookmark node, then extract the intervening nodes into a document.
- Workflow: targeted-node-extraction
- Outputs: docx
- Selected engine: mcp
programmatically-determine-start-and-end-nodes-based-on-paragraph-styles-then-extract-the.cs- Task: Programmatically determine start and end nodes based on paragraph styles, then extract the styled content segment.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
extract-a-mixed-node-range-that-starts-with-a-table-cell-and-ends-with-a-paragraph-maintai.cs- Task: Extract a mixed node range that starts with a table cell and ends with a paragraph, maintaining layout.
- Workflow: table-structured-extraction
- Outputs: docx
- Selected engine: mcp
extract-a-range-of-nodes-that-includes-tables-images-and-fields-preserving-original-hierar.cs- Task: Extract a range of nodes that includes tables, images, and fields, preserving original hierarchy in the output.
- Workflow: table-structured-extraction
- Outputs: docx
- Selected engine: mcp
extract-content-between-a-run-node-and-the-next-bookmark-then-convert-the-extracted-segmen.cs- Task: Extract content between a run node and the next bookmark, then convert the extracted segment to HTML format.
- Workflow: targeted-node-extraction
- Outputs: html
- Selected engine: mcp
extract-content-between-a-run-node-and-the-following-table-then-convert-the-extracted-port.cs- Task: Extract content between a run node and the following table, then convert the extracted portion to XPS format.
- Workflow: table-structured-extraction
- Outputs: xps
- Selected engine: mcp
use-the-extraction-api-to-copy-content-between-two-headings-and-insert-it-into-a-template.cs- Task: Use the extraction API to copy content between two headings and insert it into a template document.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
use-documentbuilder-to-prepend-extracted-node-collection-to-the-beginning-of-a-new-documen.cs- Task: Use DocumentBuilder to prepend extracted node collection to the beginning of a new document before saving.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
use-documentbuilder-to-insert-extracted-node-collection-into-a-new-document-at-a-custom-bo.cs- Task: Use DocumentBuilder to insert extracted node collection into a new document at a custom bookmark location.
- Workflow: targeted-node-extraction
- Outputs: docx
- Selected engine: llm
duplicate-extracted-content-between-a-table-and-a-field-node-within-the-original-document.cs- Task: Duplicate extracted content between a table and a field node within the original document without altering formatting.
- Workflow: table-structured-extraction
- Outputs: docx
- Selected engine: llm
save-extracted-content-as-a-docx-file-while-preserving-embedded-fields-and-their-evaluatio.cs- Task: Save extracted content as a DOCX file while preserving embedded fields and their evaluation results.
- Workflow: targeted-node-extraction
- Outputs: docx
- Selected engine: mcp
batch-process-multiple-word-files-extracting-content-between-specified-nodes-and-saving-ea.cs- Task: Batch process multiple Word files, extracting content between specified nodes and saving each extraction as an individual PDF.
- Workflow: input-bootstrap
- Outputs: pdf
- Selected engine: mcp
batch-extract-images-from-shape-nodes-in-documents-and-generate-a-csv-manifest-listing-ima.cs- Task: Batch extract images from shape nodes in documents and generate a CSV manifest listing image names and sources.
- Workflow: table-structured-extraction
- Outputs: csv
- Selected engine: mcp
extract-all-images-from-shape-nodes-across-a-document-collection-and-compile-them-into-a-s.cs- Task: Extract all images from shape nodes across a document collection and compile them into a single ZIP archive.
- Workflow: image-shape-extraction
- Outputs: docx
- Selected engine: mcp
extract-a-document-segment-that-includes-nested-tables-and-ensure-nested-structures-are-re.cs- Task: Extract a document segment that includes nested tables and ensure nested structures are retained in the new file.
- Workflow: table-structured-extraction
- Outputs: docx
- Selected engine: mcp
create-a-reusable-extraction-utility-that-accepts-node-identifiers-and-returns-a-document.cs- Task: Create a reusable extraction utility that accepts node identifiers and returns a Document containing the selected content.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
implement-error-handling-for-cases-where-the-start-node-appears-after-the-end-node-during.cs- Task: Implement error handling for cases where the start node appears after the end node during extraction.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
implement-a-custom-node-filter-to-exclude-comments-while-extracting-content-between-two-pa.cs- Task: Implement a custom node filter to exclude comments while extracting content between two paragraphs.
- Workflow: targeted-node-extraction
- Outputs: docx
- Selected engine: mcp
extract-content-between-two-bookmark-nodes-and-replace-the-original-range-with-a-placehold.cs- Task: Extract content between two bookmark nodes and replace the original range with a placeholder paragraph.
- Workflow: targeted-node-extraction
- Outputs: docx
- Selected engine: existing_repo
extract-content-between-a-paragraph-and-a-comment-node-then-log-the-extracted-text-to-a-mo.cs- Task: Extract content between a paragraph and a comment node, then log the extracted text to a monitoring system.
- Workflow: targeted-node-extraction
- Outputs: docx
- Selected engine: mcp
automate-extraction-of-footnote-content-between-specified-nodes-and-export-each-footnote-a.cs- Task: Automate extraction of footnote content between specified nodes and export each footnote as a separate text file.
- Workflow: targeted-node-extraction
- Outputs: txt
- Selected engine: mcp
create-a-command-line-tool-that-accepts-start-and-end-node-ids-and-outputs-the-extracted-s.cs- Task: Create a command-line tool that accepts start and end node IDs and outputs the extracted segment as PDF.
- Workflow: text-range-extraction
- Outputs: pdf
- Selected engine: llm
create-a-unit-test-that-verifies-extraction-of-content-between-two-specific-paragraphs-ret.cs- Task: Create a unit test that verifies extraction of content between two specific paragraphs retains original text styling.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: existing_repo
develop-a-macro-that-calls-the-extraction-api-to-copy-selected-content-into-the-clipboard.cs- Task: Develop a macro that calls the extraction API to copy selected content into the clipboard for pasting elsewhere.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: llm
extract-a-range-that-starts-inside-a-shape-s-image-and-ends-at-a-field-preserving-both-ele.cs- Task: Extract a range that starts inside a shape's image and ends at a field, preserving both elements.
- Workflow: image-shape-extraction
- Outputs: docx
- Selected engine: mcp
extract-content-between-two-nodes-in-a-document-then-encrypt-the-resulting-file-using-a-pa.cs- Task: Extract content between two nodes in a document, then encrypt the resulting file using a password.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: existing_repo
implement-parallel-processing-to-extract-node-ranges-from-multiple-documents-simultaneousl.cs- Task: Implement parallel processing to extract node ranges from multiple documents simultaneously, improving performance.
- Workflow: text-range-extraction
- Outputs: docx
- Selected engine: mcp
extract-images-from-shape-nodes-and-embed-them-directly-into-a-new-docx-document.cs- Task: Extract images from shape nodes and embed them directly into a new DOCX document.
- Workflow: image-shape-extraction
- Outputs: docx
- Selected engine: mcp
Common failure patterns and preferred agent fixes
- Invalid node insertion in destination document
- Symptom: Runtime failures such as 'Cannot insert a node of this type at this location'.
- Preferred fix: Rebuild a valid destination document structure explicitly and insert cloned inline or block nodes only into supported parents.
- Table namespace assumptions
- Symptom: Compile errors because Table, Row, or Cell were used without Aspose.Words.Tables.
- Preferred fix: Import Aspose.Words.Tables or use fully qualified table node type names.
- Weak bookmark boundary logic
- Symptom: Bookmark-bounded extraction or replacement fails because the wrong nodes are used or placeholder insertion is invalid.
- Preferred fix: Use real BookmarkStart and BookmarkEnd boundaries and insert a valid placeholder Paragraph into a supported block container.
- Footnote-specific API issues
- Symptom: Footnote export or enumeration fails because footnote APIs or namespaces are used incorrectly.
- Preferred fix: Use Aspose.Words.Notes.Footnote and Aspose.Words.Notes.FootnoteType explicitly and enumerate actual footnote nodes.
- Font or drawing ambiguity
- Symptom: Compile errors due to System.Drawing usage or ambiguous Font references.
- Preferred fix: Use Aspose.Drawing only and prefer explicit Aspose.Drawing type names when ambiguity is possible.
Build and run contract
- Target framework:
net8.0 - Package:
Aspose.Words26.9.0 - Package:
Newtonsoft.Json
Command reference
Create a temporary console project
dotnet new console -n ExampleProject --framework net8.0
cd ExampleProjectAdd required packages
dotnet add package Aspose.Words --version 26.9.0
dotnet add package Newtonsoft.JsonCopy a category example into the temp project
Copy-Item ..\extraction\<example-file>.cs .\Program.csBuild and run
dotnet build --configuration Release --verbosity minimal
dotnet run --configuration Release --no-buildCategory update guidance
- Preserve file-to-task traceability. Any future update should keep the original task text associated with the file in metadata.
- When replacing a file, prefer the latest verified publish-ready version rather than a merely compiling draft.
- Keep examples standalone, bootstrap missing inputs locally, and prefer documented Aspose APIs over speculative shortcuts.
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.

