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

agentic-net-examples / working-with-images

AGENTS.md2 starsChanged 4 months agoMITView on GitHub

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

The file

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

1 rule. About 0 are common, 1 is distinctive, and 0 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.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a Resolution object for desired DPI: Resolution {resolution} = new Resolution({int}).

    line 116

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

Working with images 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-images category. This folder contains standalone C# examples for working-with-images operations. See the root agents.md for repository-wide conventions and boundaries.

Scope

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

Required Namespaces

  • using Aspose.Pdf; (72/72 files) ← category-specific
  • using Aspose.Pdf.Devices; (10/72 files)
  • using Aspose.Pdf.Facades; (6/72 files)
  • using Aspose.Pdf.Vector; (6/72 files)
  • using Aspose.Pdf.Text; (5/72 files)
  • using Aspose.Pdf.Drawing; (4/72 files)
  • using Aspose.Pdf.Annotations; (3/72 files)
  • using Aspose.Pdf.Optimization; (2/72 files)
  • using System; (72/72 files)
  • using System.IO; (72/72 files)
  • using System.Collections.Generic; (5/72 files)
  • using System.Text.Json; (3/72 files)
  • using System.Drawing.Imaging; (2/72 files)
  • using System.Drawing; (1/72 files)
  • using System.Linq; (1/72 files)
  • using System.Security.Cryptography; (1/72 files)

Common Code Pattern

Most files follow this pattern:

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

Files in this folder

FileTitleKey APIsDescription
add-alternative-text-to-pdf-imagesAdd Alternative Text to PDF ImagesDocument, Page, XImageDemonstrates how to load a PDF, iterate through its pages and images, set alternative text for ea...
add-background-image-to-pdf-pagesAdd Background Image to PDF Pages with OpacityDocument, ImageStamp, AddStampShows how to place a semi‑transparent background image on every page of a PDF using Aspose.Pdf's ...
add-background-image-to-pdfAdd Background Image to PDF PagesDocument, Page, BackgroundArtifactShows how to place a background image on each page of an existing PDF using Aspose.Pdf, configuri...
add-background-pattern-image-to-pdf-pagesAdd Background Pattern Image to PDF PagesDocument, Page, BackgroundArtifactShows how to place a semi‑transparent background pattern image on each page of a PDF document usi...
add-centered-logo-to-first-pdf-pageAdd Centered Logo to First PDF PageDocument, Page, ImageStampShows how to load a PDF, create an ImageStamp for a logo, center it on the first page, and save t...
add-decorative-footer-image-to-pdf-pagesAdd Decorative Footer Image to PDF PagesDocument, Page, RectangleShows how to insert a footer image on every page of a PDF, scaling it proportionally to the page ...
add-diagonal-image-watermark-to-pdfAdd Diagonal Image Watermark to PDFDocument, ImageStamp, AddStampShows how to load a PDF, create an ImageStamp with a 45° rotation and semi‑transparent opacity, a...
add-dicom-image-to-pdf-pageAdd DICOM Image to PDF Page using FileStreamDocument, Page, ImageShows how to load an existing PDF, read a DICOM image via a FileStream, and place the image on a ...
add-header-image-to-pdf-pagesAdd Header Image to Each PDF PageDocument, Page, RectangleShows how to place a decorative header image at the top of every page in a PDF using Aspose.Pdf, ...
add-image-with-alt-text-to-pdfAdd Image with Alternative Text to PDFDocument, Page, RectangleShows how to insert an image into an existing PDF document and assign alternative (alt) text for ...
add-png-logo-to-first-pageAdd PNG Logo to First Page of PDFDocument, Page, RectangleShows how to load a PDF with Aspose.Pdf, place a PNG logo at specific coordinates on the first pa...
add-raster-image-to-pdf-pageAdd Raster Image to PDF PageDocument, Image, AddDemonstrates how to insert a raster image (PNG, JPEG, etc.) onto a newly created PDF page using A...
add-semi-transparent-image-watermark-to-pdf-pagesAdd Semi-Transparent Image Watermark to PDF PagesDocument, Page, ImageStampDemonstrates how to overlay a semi-transparent PNG watermark on every page of a PDF using Aspose....
add-semi-transparent-overlay-image-to-pdfAdd Semi-Transparent Overlay Image to PDFDocument, ImageStamp, PageDemonstrates how to apply a semi‑transparent PNG overlay to every page of a PDF using Aspose.Pdf,...
add-semi-transparent-overlay-to-pdf-pagesAdd Semi-Transparent Overlay to PDF Pages from Theme ConfigDocument, Page, GraphShows how to read a JSON theme file, parse a hex color with opacity, and draw a full‑page semi‑tr...
add-subtle-background-pattern-to-pdf-pagesAdd Subtle Background Pattern to PDF PagesDocument, Page, BackgroundArtifactDemonstrates how to apply a low‑opacity pattern image as a background artifact on every page of a...
add-texture-background-image-to-pdf-pagesAdd Texture Background Image to PDF PagesDocument, Page, BackgroundArtifactShows how to place a subtle texture image as a background on every page of a PDF using Aspose.Pdf...
add-transparent-png-overlay-to-pdf-pagesAdd Transparent PNG Overlay to PDF PagesDocument, Page, RectangleShows how to load a PDF, iterate through each page, and place a full‑page transparent PNG overlay...
add-vector-graphics-to-pdf-pageAdd Vector Graphics to a PDF PageDocument, Page, GraphShows how to create a new PDF page, build a Graph with rectangle, ellipse, and line shapes, and a...
batch-extract-vector-graphics-from-pdfsBatch Extract Vector Graphics from PDFsDocument, Page, SvgExtractorLoads all PDF files from a specified input folder, iterates through each page, and extracts any v...
collect-image-resolution-metadataCollect Image Resolution Metadata from PDF PagesDocument, Page, ImagePlacementAbsorberLoads a PDF, iterates through each page, finds all images using ImagePlacementAbsorber, and repor...
compress-large-images-in-pdfCompress Large Images in PDFDocument, OptimizationOptions, ImageCompressionOptionsShows how to load a PDF, configure image compression to replace images larger than 2 MB with comp...
compress-pdf-images-using-optimizationCompress Images in PDF Using Aspose.Pdf OptimizationDocument, OptimizationOptions, ImageCompressionOptionsThe example loads a PDF, configures image compression options (quality and resolution), applies r...
convert-even-pdf-pages-to-grayscaleConvert Even PDF Pages to GrayscaleDocument, PageCollection, PageShows how to load a PDF, iterate through its pages, apply a grayscale conversion only to even-num...
convert-pdf-images-to-monochromeConvert PDF Images to MonochromeDocument, Page, XImageCollectionShows how to open a PDF, iterate through each page's images, and replace them with a black‑and‑wh...
convert-pdf-pages-to-png-with-default-fontConvert PDF Pages to PNG with Default FontDocument, Page, RenderingOptionsShows how to load a PDF, set RenderingOptions.DefaultFontName to Arial, and convert each page to ...
convert-pdf-pages-to-png-with-default-font__v2Convert PDF Pages to PNG with Default Font OverrideDocument, Resolution, PngDeviceDemonstrates how to set RenderingOptions.DefaultFontName to "Times New Roman" and convert each pa...
convert-pdf-to-multi-page-tiff-default-fontConvert PDF to Multi-Page TIFF with Default FontDocument, Resolution, TiffSettingsDemonstrates converting an entire PDF document into a multi‑page TIFF file using Aspose.Pdf, sett...
copy-vector-graphics-between-pdf-pagesCopy Vector Graphics Between PDF PagesDocument, Page, GraphicsAbsorberDemonstrates how to extract vector graphic objects from a source PDF page using GraphicsAbsorber ...
correct-pdf-image-orientationCorrect PDF Image Orientation Using EXIF DataDocument, Page, XImageCollectionLoads a PDF, reads each embedded image's EXIF orientation, rotates or flips the image accordingly...
...and 42 more files

Category Statistics

  • Total examples: 72

Category-Specific Tips

Key API Surface

  • Aspose.Pdf.Devices.BmpDevice
  • Aspose.Pdf.Devices.ColorDepth
  • Aspose.Pdf.Devices.CompressionType
  • Aspose.Pdf.Devices.EmfDevice
  • Aspose.Pdf.Devices.PngDevice
  • Aspose.Pdf.Devices.Resolution
  • Aspose.Pdf.Devices.ShapeType
  • Aspose.Pdf.Devices.TiffDevice
  • Aspose.Pdf.Devices.TiffSettings
  • Aspose.Pdf.Document
  • Aspose.Pdf.Facades.PdfExtractor
  • Aspose.Pdf.Facades.PdfProducer
  • Aspose.Pdf.Image
  • Aspose.Pdf.ImportFormat
  • Aspose.Pdf.Optimization.ImageCompressionOptions

Rules

  • Load a PDF document: Document {doc} = new Document("{input_pdf}");
  • Iterate over pages using 1‑based index: for (int {page}=1; {page} <= {doc}.Pages.Count; {page}++) { ... }
  • Create a Resolution object for desired DPI: Resolution {resolution} = new Resolution({int});
  • Instantiate a PngDevice with the resolution: PngDevice pngDevice = new PngDevice({resolution});
  • Render a page to an output stream: pngDevice.Process({doc}.Pages[{page}], {output_stream});

Warnings

  • PdfProducer resides in the Aspose.Pdf.Facades namespace and may be deprecated in newer library versions; ensure the correct version is referenced.
  • A valid Aspose.PDF license is required for production use.
  • Assumes Aspose.Pdf.Devices.EmfDevice and Resolution are the correct fully qualified types; if the library version changes the namespace may differ.
  • The example manually closes the MemoryStream; using a 'using' statement is recommended to ensure proper disposal.
  • The code reads the entire file into a byte array before creating the MemoryStream; for large images a direct stream copy may be more efficient.

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-images 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.