agentic-net-examples / working-with-pdf
AGENTS.md1 starsChanged 2 months agoMITView on GitHub
Create enterprise-ready C# examples for rendering Excel workbooks or selected worksheets to PDF. Follow ../AGENTS.md, then this guide. Generated examples are discovery material, not blanket proof of API support. In scope: Workbook.Save to PDF, PdfSaveOptions, pagination, sheet/page selection, PDF/A settings, optimization, image resampling, formula refresh, fonts/warnings, and verified PDF security. Out of scope: parsing, decrypting, extracting text from, or independently validating existing PDFs; third-party PDF libraries; inferred JavaScript, multimedia, attachments, watermark, or signature APIs. Simplest conversion: Use explicit types, deterministic…
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 repository32 other files it gives its agents.
- Aspose.Cells for .NET Product AgentAGENTS.md
- calculate-formulas/AGENTS.mdAGENTS.md
- cells-data/AGENTS.mdAGENTS.md
- comments-and-notes/AGENTS.mdAGENTS.md
- conversion/AGENTS.mdAGENTS.md
- document-properties/AGENTS.mdAGENTS.md
- encryption-and-protection/AGENTS.mdAGENTS.md
- format-cells/AGENTS.mdAGENTS.md
- globalization-and-localization/AGENTS.mdAGENTS.md
- macro-project/AGENTS.mdAGENTS.md
- manage-formulas/AGENTS.mdAGENTS.md
- manage-workbook/AGENTS.mdAGENTS.md
- managing-ranges/AGENTS.mdAGENTS.md
- open-workbook/AGENTS.mdAGENTS.md
- pivot-table/AGENTS.mdAGENTS.md
- queries-and-connections/AGENTS.mdAGENTS.md
- rows-and-columns/AGENTS.mdAGENTS.md
- save-workbook/AGENTS.mdAGENTS.md
- slicer/AGENTS.mdAGENTS.md
- smart-markers/AGENTS.mdAGENTS.md
- sparkline/AGENTS.mdAGENTS.md
- timeline/AGENTS.mdAGENTS.md
- workbook-merger/AGENTS.mdAGENTS.md
- working-with-charts/AGENTS.mdAGENTS.md
- working-with-html/AGENTS.mdAGENTS.md
- working-with-images/AGENTS.mdAGENTS.md
- working-with-json/AGENTS.mdAGENTS.md
- working-with-shapes/AGENTS.mdAGENTS.md
- working-with-tables/AGENTS.mdAGENTS.md
- working-with-worksheets/AGENTS.mdAGENTS.md
- xml-maps/AGENTS.mdAGENTS.md
- llms.txtllms.txt
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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
- Very specific: line 22
Create enterprise-ready C# examples for rendering Excel workbooks or selected worksheets to PDF.
- Distinctive: line 78
Use an explicit PDF save format or options, especially for streams.
- Very specific: line 96
Use SaveFormat.Pdf for default conversion and PdfSaveOptions for selection, compliance, security, or optimization.
≈ “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
Aspose.Cells PDF Export Agent Instructions
Mission, precedence, and boundary
Create enterprise-ready C# examples for rendering Excel workbooks or selected worksheets to PDF. Follow ../AGENTS.md, then this guide. Generated examples are discovery material, not blanket proof of API support.
In scope: Workbook.Save to PDF, PdfSaveOptions, pagination, sheet/page selection, PDF/A settings, optimization, image resampling, formula refresh, fonts/warnings, and verified PDF security.
Out of scope: parsing, decrypting, extracting text from, or independently validating existing PDFs; third-party PDF libraries; inferred JavaScript, multimedia, attachments, watermark, or signature APIs.
Canonical answer
using System;
using System.IO;
using Aspose.Cells;
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells["A1"].PutValue("Item");
worksheet.Cells["B1"].PutValue("Quantity");
worksheet.Cells["A2"].PutValue("Apples");
worksheet.Cells["B2"].PutValue(10);
worksheet.AutoFitColumns();
PdfSaveOptions options = new PdfSaveOptions
{
CalculateFormula = true
};
workbook.Save("workbook.pdf", options);
if (!File.Exists("workbook.pdf") || new FileInfo("workbook.pdf").Length == 0)
{
throw new InvalidOperationException("PDF output was not created.");
}
Console.WriteLine("Saved workbook.pdf.");Simplest conversion:
workbook.Save("workbook.pdf", SaveFormat.Pdf);API truths and map
| Goal | API |
| Default conversion | Workbook.Save(path, SaveFormat.Pdf) |
| Customized conversion | Workbook.Save(path, PdfSaveOptions) |
| Page layout | Worksheet.PageSetup |
| Select worksheets | PdfSaveOptions.SheetSet |
| Select pages | PageIndex, PageCount |
| PDF/A setting | Compliance |
| PDF security | SecurityOptions |
| Optimize size | OptimizationType, SetImageResample |
| Refresh formulas | CalculateFormula or Workbook.CalculateFormula |
- Use an explicit PDF save format or options, especially for streams.
- Margins, orientation, print area, paper size, and print titles primarily belong to
Worksheet.PageSetup. PageIndexis zero-based;PageCountlimits pages.OnePagePerSheetand all-columns-on-one-page solve different layout problems.- Configuring PDF/A does not independently certify compliance.
- Aspose.Cells generates PDFs but is not a general PDF parser.
- Formula values and fonts must be current before rendering.
Example contract and validation
Use explicit types, deterministic workbook data, one PDF concern, and a named output. Include metadata for title, intent, APIs, input, output, and expected result. Build, run, check nonzero output and %PDF- signature, inspect warnings, and validate page layout visually or with an approved independent tool when required. Never hard-code production passwords.
Performance, security, and anti-patterns
Bound workbook size, page count, image DPI, concurrent exports, and temporary storage. Configure font folders in controlled deployments. Do not promise pixel-perfect output across font environments, claim configured PDF/A is certified, mix third-party parsing into a focused example, or infer APIs from filenames.
AI retrieval and FAQ
Use SaveFormat.Pdf for default conversion and PdfSaveOptions for selection, compliance, security, or optimization. Recalculate formulas before output when displayed values matter. Use PageSetup for print layout. A separate PDF component is required for parsing or certification.
Official resources
Definition of done
The example compiles, runs, uses verified PDF options, produces a nonempty PDF, validates its stated layout or option, reports warnings, and introduces no unrelated PDF dependency.
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.

