agentleFS
aspose-diagramaspose-diagram/agentic-net-examples/working-with-pages/agents.md

agentic-net-examples / working-with-pages

AGENTS.md1 starsChanged 4 months agoMITView on GitHub

AI-generated, compiler-validated C# examples for the Aspose.Diagram for .NET API — Working With Pages category. You are a C# developer specializing in Visio diagram processing using Aspose.Diagram for .NET. You are working in the Working With Pages category. Your task is to write clean, compilable C# console examples that demonstrate Aspose.Diagram API usage for working with pages operations. You always use explicit types (never var), include all required using directives, and follow the patterns established in this category. The dominant…

The file

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

12 rules. About 0 are common, 2 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use explicit types — Diagram diagram = new Diagram(...) not var diagram = ...

    line 38
  2. Very specific:

    Use SaveFileFormat enum in PascalCase: SaveFileFormat.Vsdx, SaveFileFormat.Pdf

    line 40
  3. Very specific:

    Use BOOL.True / BOOL.False for Aspose BOOL properties — never plain true/false

    line 41
  4. Very specific:

    Use var for any variable declaration

    line 53
  5. Very specific:

    Use using (Diagram diagram = ...) — Diagram does not implement IDisposable

    line 54
  6. Very specific:

    Use SaveFileFormat.VSDX or other ALL_CAPS enum values

    line 55
  7. Very specific:

    Use System.Windows.Forms — not available in net8.0 console project

    line 56
  8. Very specific:

    Use NUnit Assert — not available, use Console.WriteLine and manual checks

    line 57
  9. Distinctive:

    Use PowerShell syntax inside C# files

    line 58
  10. Distinctive:

    Check background page: page.Background == Aspose.Diagram.BOOL.True

    line 116
  11. Very specific:

    Only examples that pass both dotnet build and dotnet run are committed.

    line 367
  12. Very specific:

    Always check rules/rules.json for the latest API correction rules

    line 372

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 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

Working With Pages

AI-generated, compiler-validated C# examples for the Aspose.Diagram for .NET API — Working With Pages category.

Statistics

MetricValue
Examples168
Pass Rate100.0%
Aspose.Diagram Version26.9.0
Target Frameworknet8.0
Last Updated2026-09-24

Persona

You are a C# developer specializing in Visio diagram processing using Aspose.Diagram for .NET. You are working in the Working With Pages category. Your task is to write clean, compilable C# console examples that demonstrate Aspose.Diagram API usage for working with pages operations. You always use explicit types (never var), include all required using directives, and follow the patterns established in this category.

Boundaries

Always

  • Use explicit types — Diagram diagram = new Diagram(...) not var diagram = ...
  • Include using Aspose.Diagram; and using Aspose.Diagram.Saving; in every file
  • Use SaveFileFormat enum in PascalCase: SaveFileFormat.Vsdx, SaveFileFormat.Pdf
  • Use BOOL.True / BOOL.False for Aspose BOOL properties — never plain true/false
  • Wrap entry point in static void Main() inside class Program
  • Handle FileNotFoundException with try/catch when loading files

Ask First

  • Multi-file projects or solutions
  • External dependencies beyond Aspose.Diagram and Aspose.Drawing
  • Platform-specific code (Windows Forms, WPF, ASP.NET)

Never

  • Use var for any variable declaration
  • Use using (Diagram diagram = ...) — Diagram does not implement IDisposable
  • Use SaveFileFormat.VSDX or other ALL_CAPS enum values
  • Use System.Windows.Forms — not available in net8.0 console project
  • Use NUnit Assert — not available, use Console.WriteLine and manual checks
  • Use PowerShell syntax inside C# files

Required Namespaces

NamespaceFilesPurpose
Aspose.Diagram168Core diagram API
System168Console, Math, DateTime, Exception
System.IO136File, Stream, Path, Directory operations
Aspose.Diagram.Saving80Save options (PDF, PNG, HTML, SVG, XPS)
Aspose.Diagram.AutoLayout30Supporting utilities
System.Collections.Generic12List, Dictionary, HashSet
System.Threading.Tasks4Supporting utilities
Aspose.Diagram.Manipulation3Supporting utilities
System.Diagnostics3Supporting utilities
System.Text.Json3JSON serialization
Aspose.Drawing2Supporting utilities
System.Threading2Supporting utilities
Aspose.Diagram.Printing1Supporting utilities
Aspose.Diagram.Vba1Supporting utilities
System.Xml.Linq1Supporting utilities
System.IO.Compression1Supporting utilities

Common Code Pattern

The dominant workflow in this category is: Load → Modify → Save

using System;
using Aspose.Diagram;
using Aspose.Diagram.Saving;

class Program
{
    static void Main()
    {
        // 1. Load or create diagram
        Diagram diagram = new Diagram("input.vsdx");

        // 2. Perform category-specific operations
        // ...

        // 3. Save result
        diagram.Save("output.vsdx", SaveFileFormat.Vsdx);
    }
}

Domain Knowledge

Category-specific API rules and gotchas:

  • PAGE SIZE — Set page dimensions using page.PageSheet.PageProps.PageHeight.Value and page.PageSheet.PageProps.PageWidth.Value (values are in inches as double).
  • Example: page.PageSheet.PageProps.PageHeight.Value = 8; page.PageSheet.PageProps.PageWidth.Value = 11;
  • PAGE AUTOEXPAND — Read autoexpand state using page.PageSheet.PageProps.DrawingResizeType.Value == DrawingResizeTypeValue.Automatically.
  • Set autoexpand using page.PageSheet.PageProps.DrawingResizeType.Value = DrawingResizeTypeValue.NotAutomatically;
  • Valid DrawingResizeTypeValue members: Automatically, NotAutomatically.
  • RETRIEVE PAGE INFO — Iterate pages using foreach (Aspose.Diagram.Page page in diagram.Pages).
  • Check background page: page.Background == Aspose.Diagram.BOOL.True
  • Access page ID: page.ID
  • Access page name: page.Name
  • Access universal name: page.NameU

Examples

FileKey APIsTask
add-a-custom-shape-from-a-user-defined-master-file-to-page-five-and-set-its-text-label.csAddMaster, AddShape, DiagramAdd a custom shape from a user defined master file to page five and set its text label
add-a-dynamic-connector-shape-to-page-zero-using-the-connector-master-and-name-it-linkconnector.csAddShape, Diagram, PagesAdd a dynamic connector shape to page zero using the connector master and name it linkconnector
add-a-new-blank-page-to-an-existing-diagram-and-set-its-size-to-a4-dimensions.csDiagram, Page, PagesAdd a new blank page to an existing diagram and set its size to a4 dimensions
add-a-rectangle-shape-to-page-one-using-the-rectangle-master-and-set-its-width-to-2-inches.csAddShape, Diagram, PagesAdd a rectangle shape to page one using the rectangle master and set its width to 2 inches
adjust-printpageorientation-of-background-pages-to-portrait-while-leaving-foreground-pages-unchanged.csDiagram, Pages, SaveAdjust printpageorientation of background pages to portrait while leaving foreground pages unchanged
after-changing-page-size-refresh-the-diagram-s-page-thumbnails-to-reflect-new-dimensions.csDiagram, Pages, SaveAfter changing page size refresh the diagram s page thumbnails to reflect new dimensions
after-inserting-a-blank-page-set-its-background-property-to-true-to-designate-it-as-a-background-layer.csDiagram, Page, PagesAfter inserting a blank page set its background property to true to designate it as a background layer
after-loading-a-diagram-enumerate-pages-and-write-their-ids-and-names-to-a-csv-file.csDiagram, Pages, diagramAfter loading a diagram enumerate pages and write their ids and names to a csv file
after-resizing-recalculate-connector-routes-to-maintain-diagram-integrity-throughout.csDiagram, Layout, PagesAfter resizing recalculate connector routes to maintain diagram integrity throughout
apply-a-custom-naming-convention-to-all-pages-by-prefixing-existing-names-with-section.csDiagram, Pages, SaveApply a custom naming convention to all pages by prefixing existing names with section
apply-a-custom-page-border-style-with-dashed-lines-and-specific-thickness-to-selected-pages.csDiagram, Pages, SaveApply a custom page border style with dashed lines and specific thickness to selected pages
apply-a-minimum-page-height-constraint-to-ensure-no-page-becomes-shorter-than-5-inches.csDiagram, Pages, SaveApply a minimum page height constraint to ensure no page becomes shorter than 5 inches
apply-a-page-level-background-fill-color-to-page-one-by-modifying-the-page-backgroundfill-property.csAddShape, Diagram, PagesApply a page level background fill color to page one by modifying the page backgroundfill property
apply-a-theme-stylesheet-that-changes-the-font-family-across-all-pages-to-arial-for-consistency.csDiagram, Pages, SaveApply a theme stylesheet that changes the font family across all pages to arial for consistency
apply-a-watermark-text-to-every-page-in-a-diagram-with-adjustable-opacity-and-rotation.csDiagram, Pages, SaveApply a watermark text to every page in a diagram with adjustable opacity and rotation
apply-an-existing-stylesheet-to-page-zero-using-the-page-applystyle-method.csDiagram, Pages, SaveApply an existing stylesheet to page zero using the page applystyle method
apply-auto-spacing-across-multiple-pages-in-a-batch-process-to-standardize-diagram-layout.csAutoSpaceOptions, AutoSpaceShapes, DiagramApply auto spacing across multiple pages in a batch process to standardize diagram layout
apply-auto-spacing-to-every-shape-on-a-page-without-pre-selecting-a-specific-collection.csAutoSpaceOptions, AutoSpaceShapes, DiagramApply auto spacing to every shape on a page without pre selecting a specific collection
apply-auto-spacing-to-the-selected-shape-collection-on-a-page-using-configured-autospaceoptions.csAutoSpaceOptions, AutoSpaceShapes, DiagramApply auto spacing to the selected shape collection on a page using configured autospaceoptions
apply-dependency-injection-to-provide-autospaceoptions-to-services-handling-diagram-manipulation-for-testability.csAutoSpaceOptions, AutoSpaceShapes, DiagramApply dependency injection to provide autospaceoptions to services handling diagram manipulation for testability
apply-different-page-orientations-based-on-page-index-rotating-landscape-pages-to-portrait-dimensions.csDiagram, Pages, SaveApply different page orientations based on page index rotating landscape pages to portrait dimensions
automate-the-creation-of-a-table-of-contents-page-that-lists-all-page-titles-with-hyperlinks.csDiagram, Page, PagesAutomate the creation of a table of contents page that lists all page titles with hyperlinks
batch-process-a-folder-of-vdx-files-set-each-page-orientation-to-portrait-and-save-as-pdfs.csDiagram, Pages, PdfSaveOptionsBatch process a folder of vdx files set each page orientation to portrait and save as pdfs
batch-process-a-folder-of-visio-files-setting-each-first-page-height-to-14-inches.csDiagram, Pages, SaveBatch process a folder of visio files setting each first page height to 14 inches
benchmark-auto-spacing-performance-on-diagrams-containing-thousands-of-shapes-to-identify-bottlenecks.csAutoSpaceOptions, AutoSpaceShapes, DiagramBenchmark auto spacing performance on diagrams containing thousands of shapes to identify bottlenecks
benchmark-the-time-required-to-add-100-rectangle-shapes-to-a-single-page-and-log-the-duration.csDiagram, Pages, SaveBenchmark the time required to add 100 rectangle shapes to a single page and log the duration
cache-autospaceoptions-instances-for-reuse-across-multiple-diagrams-to-improve-performance-significantly.csAutoSpaceOptions, AutoSpaceShapes, DiagramCache autospaceoptions instances for reuse across multiple diagrams to improve performance significantly
call-the-diagram-s-validate-method-after-spacing-to-confirm-diagram-integrity-and-consistency.csAutoSpaceOptions, AutoSpaceShapes, DiagramCall the diagram s validate method after spacing to confirm diagram integrity and consistency
catch-exceptions-thrown-during-auto-spacing-and-log-error-messages-in-the-application-for-troubleshooting.csAutoSpaceOptions, AutoSpaceShapes, DiagramCatch exceptions thrown during auto spacing and log error messages in the application for troubleshooting
change-the-background-color-of-a-specific-page-to-light-gray-using-page-formatting-options.csDiagram, Page, PagesChange the background color of a specific page to light gray using page formatting options
check-whether-auto-expand-is-enabled-on-a-page-before-applying-custom-page-size-adjustments.csDiagram, Pages, SaveCheck whether auto expand is enabled on a page before applying custom page size adjustments
clone-page-two-into-a-new-page-rename-it-and-apply-a-different-stylesheet-to-the-clone.csDiagram, Page, PagesClone page two into a new page rename it and apply a different stylesheet to the clone
compare-performance-of-resizing-pages-individually-versus-applying-a-uniform-size-to-all-pages.csDiagram, Pages, SaveCompare performance of resizing pages individually versus applying a uniform size to all pages
compare-two-pages-for-visual-differences-and-generate-a-diff-report-highlighting-changed-elements.csDiagram, Pages, diagramCompare two pages for visual differences and generate a diff report highlighting changed elements
configure-a-page-to-follow-printer-defaults-by-setting-printpageorientation-sameasprinter.csDiagram, Pages, SaveConfigure a page to follow printer defaults by setting printpageorientation sameasprinter
configure-page-margins-to-0-5-inches-on-all-sides-for-page-zero-before-adding-shapes.csAddShape, Diagram, PagesConfigure page margins to 0 5 inches on all sides for page zero before adding shapes
configure-the-horizontaldistance-property-on-autospaceoptions-to-define-custom-horizontal-spacing-gaps.csAutoSpaceOptions, AutoSpaceShapes, DiagramConfigure the horizontaldistance property on autospaceoptions to define custom horizontal spacing gaps
configure-the-verticaldistance-property-on-autospaceoptions-to-define-custom-vertical-spacing-gaps.csAddShape, AutoSpaceOptions, AutoSpaceShapesConfigure the verticaldistance property on autospaceoptions to define custom vertical spacing gaps
connect-the-two-rectangle-shapes-with-the-connector-using-page-connectshapesviaconnector-specifying-source-and-target-id.csAddShape, ConnectShapesViaConnector, DiagramConnect the two rectangle shapes with the connector using page connectshapesviaconnector specifying source and target id
convert-a-page-to-svg-format-and-embed-custom-css-styles-for-shapes-and-connectors.csDiagram, SVGSaveOptions, SaveConvert a page to svg format and embed custom css styles for shapes and connectors
copy-a-page-from-a-source-diagram-modify-its-background-flag-and-add-to-destination-diagram.csDiagramCopy a page from a source diagram modify its background flag and add to destination diagram
copy-a-page-from-one-diagram-and-insert-it-into-another-diagram-at-a-specified-index.csDiagram, Page, pageCopy a page from one diagram and insert it into another diagram at a specified index
copy-a-source-page-from-one-diagram-and-add-it-to-the-target-diagram-s-end.csDiagram, Page, pageCopy a source page from one diagram and add it to the target diagram s end
copy-first-pages-from-multiple-diagrams-into-a-master-diagram-while-preserving-original-page-ids.csDiagram, Page, pageCopy first pages from multiple diagrams into a master diagram while preserving original page ids
create-a-command-line-tool-that-accepts-width-and-height-arguments-to-resize-a-specified-page.csDiagram, Pages, SaveCreate a command line tool that accepts width and height arguments to resize a specified page
create-a-gradient-fill-stylesheet-and-apply-it-to-page-five-for-visual-testing.csDiagram, Page, PagesCreate a gradient fill stylesheet and apply it to page five for visual testing
create-a-macro-that-iterates-pages-setting-height-to-match-width-for-square-layout.csDiagram, Save, diagramCreate a macro that iterates pages setting height to match width for square layout
create-a-new-blank-page-instance-and-insert-it-at-index-two-within-the-diagram.csDiagram, Page, PagesCreate a new blank page instance and insert it at index two within the diagram
create-a-new-diagram-add-a-page-with-specific-dimensions-and-save-as-vsdx.csDiagram, Page, PagesCreate a new diagram add a page with specific dimensions and save as vsdx
create-a-new-stylesheet-set-fill-color-to-light-gray-and-add-it-to-the-diagram-collection.csDiagram, Save, StyleSheetCreate a new stylesheet set fill color to light gray and add it to the diagram collection
create-a-script-that-copies-pages-from-multiple-source-diagrams-into-a-single-target-diagram-based-on-configuration.csDiagramCreate a script that copies pages from multiple source diagrams into a single target diagram based on configuration
create-a-utility-that-duplicates-every-page-renames-copies-with-a-copy-suffix-and-saves-diagram.csDiagram, Page, PagesCreate a utility that duplicates every page renames copies with a copy suffix and saves diagram
create-a-utility-that-reads-page-size-from-a-configuration-file-and-applies-it-to-each-page.csDiagram, Pages, SaveCreate a utility that reads page size from a configuration file and applies it to each page
create-an-autospaceoptions-instance-with-default-spacing-values-for-quick-layout-improvement.csAutoSpaceOptions, AutoSpaceShapes, DiagramCreate an autospaceoptions instance with default spacing values for quick layout improvement
create-pdf-save-options-that-compress-images-while-still-exporting-hidden-pages-for-archival-purposes.csDiagram, PdfSaveOptions, SaveCreate pdf save options that compress images while still exporting hidden pages for archival purposes
create-pdf-save-options-that-embed-all-fonts-enable-hidden-page-export-and-set-a-custom-document-title.csDiagram, PdfSaveOptions, SaveCreate pdf save options that embed all fonts enable hidden page export and set a custom document title
create-xps-output-from-the-diagram-while-excluding-hidden-pages-by-leaving-exporthiddenpage-false.csDiagram, Save, XPSSaveOptionsCreate xps output from the diagram while excluding hidden pages by leaving exporthiddenpage false
delete-page-three-after-confirming-it-contains-no-shapes-to-preserve-data-integrity.csDiagram, Pages, SaveDelete page three after confirming it contains no shapes to preserve data integrity
delete-the-third-page-from-a-diagram-and-renumber-the-remaining-pages-sequentially.csDiagram, Pages, SaveDelete the third page from a diagram and renumber the remaining pages sequentially
detect-and-list-any-orphan-shapes-on-a-page-that-are-not-connected-to-any-other-shape.csDiagram, Pages, ShapesDetect and list any orphan shapes on a page that are not connected to any other shape
detect-pages-with-auto-expand-enabled-and-log-their-original-dimensions-before-resizing.csDiagram, Pages, SaveDetect pages with auto expand enabled and log their original dimensions before resizing
document-auto-spacing-usage-examples-in-generated-api-documentation-for-developer-reference-clearly.csAutoSpaceOptions, AutoSpaceShapes, DiagramDocument auto spacing usage examples in generated api documentation for developer reference clearly
enable-inclusion-of-hidden-pages-when-saving-to-pdf-by-setting-exporthiddenpage-true.csDiagram, PdfSaveOptions, SaveEnable inclusion of hidden pages when saving to pdf by setting exporthiddenpage true
enable-page-grid-visibility-on-page-two-to-assist-with-manual-shape-alignment.csDiagram, Pages, SaveEnable page grid visibility on page two to assist with manual shape alignment
ensure-custom-data-fields-attached-to-shapes-are-preserved-during-auto-spacing-processing.csAutoSpaceOptions, AutoSpaceShapes, DiagramEnsure custom data fields attached to shapes are preserved during auto spacing processing
export-a-diagram-after-auto-spacing-to-svg-format-to-preserve-vector-quality-for-web-display.csAutoSpaceOptions, AutoSpaceShapes, DiagramExport a diagram after auto spacing to svg format to preserve vector quality for web display
export-a-diagram-with-modified-page-dimensions-to-pdf-while-preserving-original-layout.csDiagram, Pages, PdfSaveOptionsExport a diagram with modified page dimensions to pdf while preserving original layout
export-a-selected-page-as-a-high-resolution-png-image-with-custom-dpi-settings.csDiagram, ImageSaveOptions, SaveExport a selected page as a high resolution png image with custom dpi settings
export-page-comments-and-annotations-to-a-separate-xml-document-for-external-review.csDiagram, Pages, diagramExport page comments and annotations to a separate xml document for external review
export-resized-pages-to-separate-vsdx-files-naming-each-file-after-its-page-index.csDiagram, diagramExport resized pages to separate vsdx files naming each file after its page index
export-the-auto-spaced-diagram-to-pdf-format-for-sharing-with-non-visio-users.csDiagram, Save, diagramExport the auto spaced diagram to pdf format for sharing with non visio users
export-the-auto-spaced-diagram-to-xps-format-to-enable-high-quality-printing-capabilities.csAutoSpaceOptions, AutoSpaceShapes, DiagramExport the auto spaced diagram to xps format to enable high quality printing capabilities
export-the-diagram-to-png-format-ensuring-hidden-pages-are-omitted-by-default-settings.csDiagram, Save, diagramExport the diagram to png format ensuring hidden pages are omitted by default settings
extract-all-shape-names-and-their-positions-from-a-given-page-and-write-them-to-a-csv-file.csDiagram, Pages, ShapesExtract all shape names and their positions from a given page and write them to a csv file
filter-shapes-on-a-page-by-type-and-remove-all-connector-shapes-programmatically.csDiagram, Pages, SaveFilter shapes on a page by type and remove all connector shapes programmatically
find-a-page-using-its-textual-name-via-getpage-method-and-set-uivisibility-to-false.csDiagram, Pages, SaveFind a page using its textual name via getpage method and set uivisibility to false
generate-a-pdf-report-listing-each-page-s-metadata-and-include-thumbnails-from-hidden-pages.csDiagram, ImageSaveOptions, PagesGenerate a pdf report listing each page s metadata and include thumbnails from hidden pages
generate-a-report-listing-each-page-s-original-and-new-dimensions-after-size-modification.csDiagram, Pages, SaveGenerate a report listing each page s original and new dimensions after size modification
generate-a-summary-report-listing-each-page-name-shape-count-and-connector-count.csDiagram, Pages, ShapesGenerate a summary report listing each page name shape count and connector count
generate-a-thumbnail-image-for-each-page-in-a-diagram-and-store-them-in-a-zip-archive.csDiagram, ImageSaveOptions, PagesGenerate a thumbnail image for each page in a diagram and store them in a zip archive
generate-an-svg-file-from-the-diagram-and-explicitly-include-hidden-pages-by-enabling-exporthiddenpage.csDiagram, SVGSaveOptions, SaveGenerate an svg file from the diagram and explicitly include hidden pages by enabling exporthiddenpage
hide-a-background-page-by-setting-its-uivisibility-property-to-false-preventing-export.csDiagram, Pages, PdfSaveOptionsHide a background page by setting its uivisibility property to false preventing export
implement-a-function-that-returns-true-if-any-page-in-a-diagram-is-hidden-using-uivisibility-checks.csDiagram, Pages, diagramImplement a function that returns true if any page in a diagram is hidden using uivisibility checks
implement-an-asynchronous-method-to-perform-auto-spacing-without-blocking-the-ui-thread.csAutoSpaceOptions, AutoSpaceShapes, DiagramImplement an asynchronous method to perform auto spacing without blocking the ui thread
implement-error-handling-for-invalid-page-size-values-when-assigning-to-pageprops.csDiagram, Pages, SaveImplement error handling for invalid page size values when assigning to pageprops
implement-error-handling-to-catch-exceptions-when-applying-a-stylesheet-to-a-non-existent-page-index.csDiagram, Pages, SaveImplement error handling to catch exceptions when applying a stylesheet to a non existent page index
implement-unit-tests-verifying-that-pageprops-width-setter-throws-exception-for-negative-values.csDiagram, Pages, diagramImplement unit tests verifying that pageprops width setter throws exception for negative values
insert-a-header-footer-on-each-page-containing-page-number-and-diagram-title-dynamically.csDiagram, Save, diagramInsert a header footer on each page containing page number and diagram title dynamically
insert-a-second-rectangle-shape-on-page-zero-assign-a-unique-id-and-position-at-coordinates-2-3.csAddShape, Diagram, PagesInsert a second rectangle shape on page zero assign a unique id and position at coordinates 2 3
insert-three-blank-pages-at-the-beginning-of-a-diagram-to-serve-as-placeholders.csDiagram, Page, PagesInsert three blank pages at the beginning of a diagram to serve as placeholders
iterate-over-all-pages-and-apply-a-common-stylesheet-to-each-page.csDiagram, Pages, SaveIterate over all pages and apply a common stylesheet to each page
iterate-through-all-pages-increase-each-page-width-by-10-percent-and-overwrite-original-file.csDiagram, Pages, SaveIterate through all pages increase each page width by 10 percent and overwrite original file
iterate-through-diagram-pages-to-log-each-page-s-id-name-and-background-flag.csDiagram, Pages, SaveIterate through diagram pages to log each page s id name and background flag
load-a-diagram-change-orientation-of-every-non-background-page-to-landscape-and-export-to-xps.csDiagram, Pages, SaveLoad a diagram change orientation of every non background page to landscape and export to xps
load-a-diagram-clone-the-third-page-modify-its-height-and-insert-into-the-same-file.csDiagram, Page, PagesLoad a diagram clone the third page modify its height and insert into the same file
load-a-diagram-from-a-byte-array-apply-changes-to-a-page-and-write-to-a-byte-array.csDiagram, Pages, SaveLoad a diagram from a byte array apply changes to a page and write to a byte array
load-a-diagram-from-a-network-stream-modify-a-specific-page-and-save-back-to-the-same-stream.csDiagram, Pages, SaveLoad a diagram from a network stream modify a specific page and save back to the same stream
load-a-diagram-set-page-height-based-on-number-of-shapes-then-save-changes.csDiagram, Pages, SaveLoad a diagram set page height based on number of shapes then save changes
load-a-diagram-temporarily-disable-page-auto-expand-modify-size-then-re-enable-auto-expand.csDiagram, Pages, SaveLoad a diagram temporarily disable page auto expand modify size then re enable auto expand
load-a-vdx-diagram-file-into-a-diagram-object-and-verify-successful-initialization.csDiagram, Pages, diagramLoad a vdx diagram file into a diagram object and verify successful initialization
load-a-visio-diagram-change-the-first-page-width-to-8-5-inches-and-save.csDiagram, Pages, SaveLoad a visio diagram change the first page width to 8 5 inches and save
load-a-visio-diagram-from-a-file-and-obtain-its-diagram-object-for-further-processing.csDiagramLoad a visio diagram from a file and obtain its diagram object for further processing
load-a-visio-diagram-from-a-file-stream-and-verify-at-least-one-page-exists.csDiagram, Pages, diagramLoad a visio diagram from a file stream and verify at least one page exists
load-a-visio-diagram-from-a-memory-stream-and-create-a-diagram-instance-for-manipulation.csDiagram, Pages, diagramLoad a visio diagram from a memory stream and create a diagram instance for manipulation
load-a-visio-vsdx-file-and-retrieve-the-total-number-of-pages-in-the-diagram.csDiagram, Pages, diagramLoad a visio vsdx file and retrieve the total number of pages in the diagram
load-a-vsdx-diagram-using-the-diagram-constructor-and-ensure-all-pages-are-accessible.csDiagram, Pages, diagramLoad a vsdx diagram using the diagram constructor and ensure all pages are accessible
load-autospaceoptions-settings-from-a-json-file-before-applying-spacing-to-customize-behavior.csAutoSpaceOptions, AutoSpaceShapes, DiagramLoad autospaceoptions settings from a json file before applying spacing to customize behavior
load-diagrams-from-both-vdx-and-vsdx-formats-in-a-single-routine-with-automatic-detection.csDiagram, Pages, diagramLoad diagrams from both vdx and vsdx formats in a single routine with automatic detection
log-details-of-each-shape-s-new-position-to-the-console-after-auto-spacing-completes.csAutoSpaceOptions, AutoSpaceShapes, DiagramLog details of each shape s new position to the console after auto spacing completes
measure-content-bounding-box-then-adjust-page-width-to-tightly-fit-all-shapes-on-the-page.csDiagram, Pages, SaveMeasure content bounding box then adjust page width to tightly fit all shapes on the page
measure-the-total-number-of-connectors-on-each-page-and-store-the-counts-in-a-dictionary.csDiagram, Pages, ShapesMeasure the total number of connectors on each page and store the counts in a dictionary
merge-multiple-diagrams-by-appending-all-pages-from-each-source-into-a-single-target-diagram.csDiagramMerge multiple diagrams by appending all pages from each source into a single target diagram
mock-diagram-and-page-objects-to-isolate-and-test-auto-spacing-logic-without-loading-actual-files.csAutoSpaceOptions, AutoSpaceShapes, DiagramMock diagram and page objects to isolate and test auto spacing logic without loading actual files
move-a-hidden-page-to-the-end-of-the-page-collection-and-verify-uivisibility-remains-false.csDiagram, Pages, SaveMove a hidden page to the end of the page collection and verify uivisibility remains false
move-the-third-page-to-the-first-position-using-pages-move-to-reorder-layout.csDiagram, Pages, SaveMove the third page to the first position using pages move to reorder layout
optimize-page-content-by-flattening-groups-and-simplifying-complex-shapes-for-faster-rendering.csDiagram, Pages, SaveOptimize page content by flattening groups and simplifying complex shapes for faster rendering
perform-batch-conversion-of-all-pages-in-a-diagram-to-individual-pdf-files-using-parallel-processing.csDiagram, Pages, PdfSaveOptionsPerform batch conversion of all pages in a diagram to individual pdf files using parallel processing
programmatically-disable-auto-expand-then-assign-a-fixed-page-size-to-prevent-automatic-scaling.csDiagram, Pages, SaveProgrammatically disable auto expand then assign a fixed page size to prevent automatic scaling
programmatically-hide-all-background-pages-in-the-diagram-then-save-to-pdf-with-hidden-pages-excluded.csDiagram, Pages, PdfSaveOptionsProgrammatically hide all background pages in the diagram then save to pdf with hidden pages excluded
programmatically-set-uivisibility-to-true-for-all-pages-then-export-to-pdf-ensuring-no-hidden-pages.csDiagram, Pages, PdfSaveOptionsProgrammatically set uivisibility to true for all pages then export to pdf ensuring no hidden pages
provide-a-sample-code-snippet-demonstrating-auto-spacing-with-custom-horizontal-and-vertical-distances.csAutoSpaceOptions, AutoSpaceShapes, DiagramProvide a sample code snippet demonstrating auto spacing with custom horizontal and vertical distances
recalculate-connector-routing-after-auto-spacing-to-avoid-overlapping-or-broken-connections-in-the-diagram.csAutoSpaceOptions, AutoSpaceShapes, DiagramRecalculate connector routing after auto spacing to avoid overlapping or broken connections in the diagram
reconnect-the-same-shapes-using-page-connectshapesviaconn-method-and-compare-routing-results.csAddShape, ConnectShapesViaConnector, DiagramReconnect the same shapes using page connectshapesviaconn method and compare routing results
render-a-page-to-a-bitmap-image-using-anti-aliasing-and-transparent-background-options.csDiagram, ImageSaveOptions, SaveRender a page to a bitmap image using anti aliasing and transparent background options
reorder-pages-by-moving-the-last-page-to-the-second-position-within-the-diagram.csDiagram, Pages, SaveReorder pages by moving the last page to the second position within the diagram
replace-the-background-image-of-a-page-with-a-new-image-file-while-preserving-aspect-ratio.csAddShape, Diagram, PagesReplace the background image of a page with a new image file while preserving aspect ratio
resize-all-shapes-on-a-page-proportionally-to-fit-within-a-new-page-margin-configuration.csDiagram, Pages, SaveResize all shapes on a page proportionally to fit within a new page margin configuration
retrieve-a-specific-page-by-its-name-from-the-loaded-diagram-to-target-shape-operations.csDiagram, Pages, ShapesRetrieve a specific page by its name from the loaded diagram to target shape operations
retrieve-a-specific-page-by-its-numeric-id-and-store-the-reference-for-later-modifications.csDiagram, Pages, SaveRetrieve a specific page by its numeric id and store the reference for later modifications
retrieve-all-pages-in-the-diagram-and-iterate-through-them-to-apply-batch-auto-spacing.csAutoSpaceOptions, AutoSpaceShapes, DiagramRetrieve all pages in the diagram and iterate through them to apply batch auto spacing
retrieve-each-page-s-name-and-log-it-to-the-console-for-audit-purposes.csDiagram, Pages, diagramRetrieve each page s name and log it to the console for audit purposes
retrieve-page-properties-for-the-second-page-set-height-to-11-inches-then-export-to-vdx.csDiagram, Pages, SaveRetrieve page properties for the second page set height to 11 inches then export to vdx
save-a-particular-page-as-a-pdf-document-while-preserving-vector-graphics-and-text-quality.csDiagram, PdfSaveOptions, SaveSave a particular page as a pdf document while preserving vector graphics and text quality
save-the-diagram-containing-hidden-pages-to-html-while-preserving-their-visibility-using-htmlsaveoptions.csDiagram, HTMLSaveOptions, SaveSave the diagram containing hidden pages to html while preserving their visibility using htmlsaveoptions
save-the-modified-diagram-to-a-memory-stream-for-further-processing-or-transmission.csDiagram, Pages, SaveSave the modified diagram to a memory stream for further processing or transmission
save-the-updated-diagram-to-a-new-file-while-preserving-the-original-visio-format.csDiagram, Pages, SaveSave the updated diagram to a new file while preserving the original visio format
select-a-shape-collection-by-shape-ids-to-prepare-for-custom-spacing-adjustments.csDiagram, Pages, SaveSelect a shape collection by shape ids to prepare for custom spacing adjustments
select-shapes-based-on-their-master-name-to-apply-targeted-auto-spacing-on-similar-objects.csDiagram, Pages, SaveSelect shapes based on their master name to apply targeted auto spacing on similar objects
serialize-autospaceoptions-configuration-to-json-for-external-configuration-management-and-version-control.csAutoSpaceOptions, Diagram, PagesSerialize autospaceoptions configuration to json for external configuration management and version control
set-exporthiddenpage-to-true-for-html-png-and-svg-saves-in-a-loop-to-generate-outputs.csDiagram, HTMLSaveOptions, ImageSaveOptionsSet exporthiddenpage to true for html png and svg saves in a loop to generate outputs
set-horizontaldistance-to-zero-in-autospaceoptions-to-align-shapes-vertically-without-horizontal-gaps.csAutoSpaceOptions, AutoSpaceShapes, DiagramSet horizontaldistance to zero in autospaceoptions to align shapes vertically without horizontal gaps
set-page-orientation-to-landscape-for-page-four-using-the-page-orientation-property.csDiagram, Pages, SaveSet page orientation to landscape for page four using the page orientation property
set-page-protection-to-read-only-mode-and-assign-a-password-for-editing-restrictions.csDiagram, Save, diagramSet page protection to read only mode and assign a password for editing restrictions
set-the-connector-s-line-weight-to-0-5-points-and-change-its-line-color-to-dark-blue.csDiagram, Pages, SaveSet the connector s line weight to 0 5 points and change its line color to dark blue
set-the-orientation-of-a-page-to-landscape-and-adjust-its-width-and-height-accordingly.csDiagram, Pages, SaveSet the orientation of a page to landscape and adjust its width and height accordingly
set-the-orientation-of-a-selected-page-to-landscape-by-assigning-printpageorientation-landscape.csDiagram, Pages, SaveSet the orientation of a selected page to landscape by assigning printpageorientation landscape
set-the-orientation-of-all-pages-to-landscape-then-generate-a-pdf-and-verify-page-dimensions-reflect-rotation.csDiagram, Pages, PdfSaveOptionsSet the orientation of all pages to landscape then generate a pdf and verify page dimensions reflect rotation
set-the-page-background-color-to-white-for-all-pages-using-a-loop-and-a-single-stylesheet.csDiagram, Pages, SaveSet the page background color to white for all pages using a loop and a single stylesheet
set-verticaldistance-to-zero-in-autospaceoptions-to-align-shapes-horizontally-without-vertical-gaps.csAutoSpaceOptions, AutoSpaceShapes, DiagramSet verticaldistance to zero in autospaceoptions to align shapes horizontally without vertical gaps
translate-page-metadata-into-a-localized-language-using-a-resource-dictionary-before-saving.csDiagram, Save, diagramTranslate page metadata into a localized language using a resource dictionary before saving
update-the-page-title-property-based-on-external-metadata-retrieved-from-a-json-file.csDiagram, Save, diagramUpdate the page title property based on external metadata retrieved from a json file
use-a-cancellation-token-to-abort-the-auto-spacing-operation-if-the-user-requests-cancellation.csAutoSpaceOptions, AutoSpaceShapes, DiagramUse a cancellation token to abort the auto spacing operation if the user requests cancellation
use-a-lambda-expression-to-set-page-width-based-on-page-index-parity.csDiagram, Pages, SaveUse a lambda expression to set page width based on page index parity
use-a-try-catch-block-around-the-auto-spacing-call-to-gracefully-handle-runtime-errors.csAutoSpaceOptions, AutoSpaceShapes, DiagramUse a try catch block around the auto spacing call to gracefully handle runtime errors
use-a-try-finally-block-to-ensure-the-diagram-object-is-disposed-even-if-processing-fails.csDiagram, Save, diagramUse a try finally block to ensure the diagram object is disposed even if processing fails
use-asynchronous-loading-of-diagrams-while-preparing-page-size-adjustments-in-parallel-threads.csDiagram, Pages, SaveUse asynchronous loading of diagrams while preparing page size adjustments in parallel threads
use-negative-spacing-values-in-autospaceoptions-to-intentionally-overlap-shapes-for-compact-layout.csAddShape, AutoSpaceOptions, AutoSpaceShapesUse negative spacing values in autospaceoptions to intentionally overlap shapes for compact layout
use-pageprops-to-copy-size-from-a-template-page-to-multiple-target-pages-within-a-diagram.csDiagram, Pages, SaveUse pageprops to copy size from a template page to multiple target pages within a diagram
validate-page-dimensions-against-a-predefined-template-and-report-any-mismatches-in-a-log.csDiagram, Pages, diagramValidate page dimensions against a predefined template and report any mismatches in a log
validate-shape-positions-after-auto-spacing-by-comparing-their-x-and-y-coordinates-to-expected-values.csAutoSpaceOptions, AutoSpaceShapes, DiagramValidate shape positions after auto spacing by comparing their x and y coordinates to expected values
validate-that-each-page-contains-at-least-one-shape-after-batch-adding-shapes-to-all-pages.csDiagram, Page, PagesValidate that each page contains at least one shape after batch adding shapes to all pages
validate-that-every-page-in-the-loaded-diagram-has-a-unique-name-raising-an-exception-on-duplicates.csDiagram, Pages, diagramValidate that every page in the loaded diagram has a unique name raising an exception on duplicates
validate-that-page-names-are-unique-across-the-diagram-after-renaming-pages-programmatically.csDiagram, Pages, SaveValidate that page names are unique across the diagram after renaming pages programmatically
validate-that-page-size-changes-persist-after-closing-and-reopening-the-visio-document.csDiagram, Pages, SaveValidate that page size changes persist after closing and reopening the visio document
validate-that-saved-diagram-retains-custom-page-size-when-opened-in-microsoft-visio.csDiagram, Page, PagesValidate that saved diagram retains custom page size when opened in microsoft visio
verify-that-all-connectors-stay-attached-to-their-source-and-target-shapes-after-spacing-operation.csAutoSpaceOptions, AutoSpaceShapes, DiagramVerify that all connectors stay attached to their source and target shapes after spacing operation
write-a-csv-file-summarizing-shape-ids-and-their-new-coordinates-following-auto-spacing.csAutoSpaceOptions, AutoSpaceShapes, DiagramWrite a csv file summarizing shape ids and their new coordinates following auto spacing
write-unit-tests-asserting-that-shape-positions-match-expected-coordinates-after-applying-auto-spacing.csAutoSpaceOptions, AutoSpaceShapes, DiagramWrite unit tests asserting that shape positions match expected coordinates after applying auto spacing

Command Reference

# Build the warmup project
cd compiler/CSharpRunner/_warmup
dotnet build

# Run a specific example (copy .cs content to Program.cs first)
dotnet run

# Build with verbose output
dotnet build --verbosity detailed

.csproj Template

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>disable</ImplicitUsings>
    <NoWarn>MSB3277</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Aspose.Diagram">
      <HintPath>..\..\libs\Aspose.Diagram.dll</HintPath>
    </Reference>
  </ItemGroup>
</Project>

Testing Guide

Build Verification

dotnet build  # Must exit with rc=0, zero compiler errors

Run Verification

dotnet run    # rc=0 = pass, rc!=0 with unhandled exception = fail

Expected Output Patterns

PatternMeaning
rc=0✅ Pass — example compiled and ran successfully
rc=1 compiler errors❌ Fail — CS error codes indicate API misuse
rc!=0 runtime⚠️ Check — may be acceptable (missing input file)
TIMEOUT✅ Pass — Console.ReadLine() treated as successful completion

Common CS Error Codes

CodeMeaningFix
CS1061Member does not existCheck correct property/method name
CS0200Property is read-onlyAccess via .Value instead of assignment
CS0029Cannot convert typeUse correct enum type (BOOL not bool)
CS0117Name does not exist in typeCheck enum member name casing
CS0234Namespace not foundAdd correct using directive

Pipeline

AttemptStrategyTrigger
1MCP direct retrieval + code assemblyAlways
2MCP retrieval with injected rulesAttempt 1 fails
3LLM repair with compiler errors + rulesAttempt 2 fails

Only examples that pass both dotnet build and dotnet run are committed.

General Tips

  • See root agents.md for repository-wide boundaries, anti-patterns, domain knowledge, and testing guidelines
  • Always check rules/rules.json for the latest API correction rules
  • SaveFileFormat enum must always be PascalCase: Vsdx, Pdf, Png, Jpeg, Svg, Html — never ALL_CAPS
  • Diagram class does NOT implement IDisposable — never use using (Diagram ...)

Key API Surface

  • AddMaster
  • AddShape
  • AutoSpaceOptions
  • AutoSpaceShapes
  • ConnectShapesViaConnector
  • Diagram
  • HTMLSaveOptions
  • ImageSaveOptions
  • Layout
  • Page
  • Pages
  • PdfSaveOptions
  • SVGSaveOptions
  • Save
  • Shape
  • Shapes
  • StyleSheet
  • StyleSheets
  • Window
  • Windows
  • XPSSaveOptions
  • diagram
  • page
  • shape
  • stylesheet

Real-World Use Cases

Common scenarios where Aspose.Diagram for .NET working with pages capabilities are applied in production applications:

  • Managing multi-page Visio documents in enterprise content management systems
  • Reordering pages in automated report generation workflows
  • Adding background pages for watermarks and corporate branding
  • Copying pages between diagrams in document merge operations

Developer Q&A

Frequently asked questions about Working With Pages in Aspose.Diagram for .NET:

Q: How do I get started with Working With Pages in Aspose.Diagram for .NET?

A: Add a reference to Aspose.Diagram.dll (v26.9.0), include using Aspose.Diagram; and using Aspose.Diagram.Saving;, then use Diagram diagram = new Diagram("input.vsdx"); to load a file. All examples in this category target net8.0.

Q: Why do I get CS1674 when using using (Diagram diagram = ...)?

A: Diagram does not implement IDisposable in Aspose.Diagram for .NET. Remove the using statement and declare the variable normally: Diagram diagram = new Diagram("input.vsdx");

Q: Why does my code fail with CS0117 on SaveFileFormat.VSDX?

A: SaveFileFormat enum members use PascalCase in Aspose.Diagram for .NET. Use SaveFileFormat.Vsdx (not VSDX). The same applies to all formats: SaveFileFormat.Pdf, SaveFileFormat.Png, SaveFileFormat.Svg.

Q: Why do I get CS0029 when assigning true to a BOOL property?

A: Aspose.Diagram uses its own BOOL enumeration type, not C# bool. Use BOOL.True and BOOL.False instead of plain true/false for all Aspose.Diagram BOOL properties.

Q: How do I access a page by name?

A: Use diagram.Pages.GetPage("PageName"). To access by index use diagram.Pages[0]. Never use diagram.ActivePage — it does not exist.

Q: How do I add a new blank page to a diagram?

A: Create Page newPage = new Page(); newPage.Name = "NewPage"; newPage.ID = maxId + 1; diagram.Pages.Add(newPage); where maxId is the maximum existing page ID.

Related Categories

Category Statistics

  • Total examples: 168
  • Failed: 0
  • Pass rate: 100.0%

Failed Tasks

All tasks passed ✅


Updated: 2026-09-24 | Examples: 168 | Pass Rate: 100.0% | ↑ Root agents.md | Aspose.Diagram for .NET

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.