agentleFS
aspose-cellsaspose-cells/agentic-net-examples/working-with-pdf/AGENTS.md

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…

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
  1. Very specific:

    Create enterprise-ready C# examples for rendering Excel workbooks or selected worksheets to PDF.

    line 22
  2. Distinctive:

    Use an explicit PDF save format or options, especially for streams.

    line 78
  3. Very specific:

    Use SaveFormat.Pdf for default conversion and PdfSaveOptions for selection, compliance, security, or optimization.

    line 96

≈ “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

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

GoalAPI
Default conversionWorkbook.Save(path, SaveFormat.Pdf)
Customized conversionWorkbook.Save(path, PdfSaveOptions)
Page layoutWorksheet.PageSetup
Select worksheetsPdfSaveOptions.SheetSet
Select pagesPageIndex, PageCount
PDF/A settingCompliance
PDF securitySecurityOptions
Optimize sizeOptimizationType, SetImageResample
Refresh formulasCalculateFormula 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.
  • PageIndex is zero-based; PageCount limits pages.
  • OnePagePerSheet and 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.

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.