Page
Overview
Page is a class in Aspose.PDF FOSS for .NET.
Inherits from: IDisposable.
Represents a page in a PDF document.
This class declares 62 methods for Page objects in .NET programs.
Available methods include: Accept, AddContent, AddContentStream, AddExtGState, AddFloatingBox, AddGraph, AddGraphics, AddImage, AddLuminositySoftMask, AddPattern, AddShading, AddStamp, and 32 additional methods.
Public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: Actions, Annotations, ArtBox, Artifacts, Background, BackgroundImage, and 36 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
Number | int | Read | 1-based page number. |
FieldsInTabOrder | IList<Forms.Field> | Read | Form fields whose widgets appear on this page, ordered by their tab order. |
Rect | Rectangle | Read/Write | Page rectangle (defaults to MediaBox). |
Rectangle | Rectangle | Read/Write | The page rectangle. |
PageInfo | PageInfo | Read/Write | Page info container with width/height/margin properties. |
Background | Color? | Read/Write | Page background colour. |
MediaBox | Rectangle | Read/Write | The media box for this page (required per spec). |
CropBox | Rectangle | Read/Write | The crop box (defaults to media box). |
BleedBox | Rectangle | Read/Write | The bleed box (defaults to crop box). |
TrimBox | Rectangle | Read/Write | The trim box (defaults to crop box). |
ArtBox | Rectangle | Read/Write | The art box (defaults to crop box). |
Rotate | Rotation | Read/Write | Page rotation as Rotation enum. |
RotateDegrees | int | Read/Write | Page rotation in degrees as int (0, 90, 180, 270). |
RotationMatrix | Matrix | Read | Affine transform that maps the unrotated PDF coordinate system to the page’s user-visible (rotated) one. |
Duration | double | Read/Write | Page display duration in seconds for presentation mode. |
Annotations | AnnotationCollection | Read | Annotations on this page. |
Resources | Resources | Read | Page resources (fonts, images) — provides access via a unified Resources object. |
Patterns | IReadOnlyDictionary<string, Pattern> | Read | Pattern resources on this page (keyed by pattern name). |
Width | double | Read | Visible page width accounting for rotation. |
Height | double | Read | Visible page height accounting for rotation. |
ColorType | ColorType | Read | Gets the color type of this page by analyzing its content stream operators and image color spaces. |
Transition | PageTransition? | Read | The page transition effect, or null if none is set. |
Header | HeaderFooter? | Read/Write | Header to render at the top of this page. |
Footer | HeaderFooter? | Read/Write | Footer to render at the bottom of this page. |
TocInfo | TocInfo? | Read/Write | TOC information for this page. |
ColumnInfo | ColumnInfo? | Read/Write | The columns the page’s paragraphs flow in, left to right: the first is filled top to bottom, then the next, and only after the last does the flow go on to a new page, whose paragraphs fill the same columns. |
Paragraphs | Paragraphs | Read/Write | Collection of paragraph objects to add to this page (TextFragment, HtmlFragment, Table, Heading, etc.). |
NoteLineStyle | GraphInfo | Read/Write | Default stroke/fill style used to draw footnote / endnote separator lines. |
Artifacts | ArtifactCollection | Read | Collection for adding artifacts (watermarks, etc.) to this page. |
OcgLayers | LayerCollection | Read | Gets the layers (Optional Content Groups) referenced by this page. |
Actions | PageActionCollection | Read | Per-page additional actions (open / close / etc.), backed by /AA. |
UserUnit | double | Read/Write | User-unit factor (PDF 32000 §14.8.4 /UserUnit entry). |
IsAddParagraphsAfterLast | bool | Read/Write | Whether Paragraphs additions append at the end (vs flow position). |
Group | Group? | Read/Write | Group / blending colour space dictionary for this page. |
TabOrder | TabOrder | Read/Write | Tab order (PDF 32000 §12.5 /Tabs entry). |
Watermark | Watermark? | Read/Write | The page watermark. |
Contents | OperatorCollection | Read | Content stream operator collection. |
ContentsAppender | ContentsAppender | Read | Helper that buffers operators to prepend to / append to this page’s content stream, applied on UpdateData. |
Images | XImageCollection | Read | Image XObjects on this page. |
BackgroundImage | Image? | Read/Write | Page background image. |
Layers | System.Collections.Generic.List<Layer> | Read/Write | The page’s layers (Optional Content Groups). |
Fonts | FontCollection | Read | Fonts referenced by this page. |
Methods
| Signature | Description |
|---|---|
SetRotation(degrees: int) | Set the page rotation in degrees (0, 90, 180, 270). |
Accept(visitor: Annotations.AnnotationSelector) | Walk every annotation on this page through visitor; matches accumulate in Selected. |
GetResources() | Method-style accessor for Resources — public-API compatibility. |
Accept(visitor: Text.TextAbsorber) | Accept a TextAbsorber visitor (matching the public API). |
GetText() | Extract all text from the page using a TextAbsorber. |
Accept(visitor: Text.TextFragmentAbsorber) | Accept a TextFragmentAbsorber visitor (matching the public API). |
GetTextRotationStatistic() | Tally how many text fragments on this page are drawn at each rotation angle. |
Accept(visitor: ImagePlacementAbsorber) | Accept an ImagePlacementAbsorber visitor (matching the public API). |
SendTo(device: Devices.ImageDevice, outputFileName: string) | Add a stamp to this page. |
SendTo(device: Devices.ImageDevice, output: Stream) | Render this page using the specified device and write to a stream. |
AsByteArray(resolution: Aspose.Pdf.Devices.Resolution) | Render this page into a PNG byte array at the requested resolution. |
ConvertToPNGMemoryStream() | Convenience helper: render this page to a PNG and return the bytes as a MemoryStream. |
MergeLayers(newLayerName: string) | Merge all layers on this page into a single layer with the given name. |
MergeLayers(newLayerName: string, newOptionalContentGroupId: string) | Merge all layers on this page, assigning the new OCG the given id. |
TrySaveVectorGraphics(pathToSave: string) | Writes the page’s vector graphics as one SVG sized to the page; false when the page draws none. |
AsXml() | Diagnostic XML representation of this page. |
GetNotifications() | Line-break notifications emitted by the flow layout for this page when EnableNotificationLogging was set before save. |
MakeGrayscale() | Convert this page’s colours to grayscale: content-stream colour operators, image XObjects, named colour-space resources, and annotation appearances. |
IntToRotation(rotation: int) | Convert a degrees-int rotation to Rotation. |
RotationToInt(rotation: Rotation) | Convert Rotation to degrees as an int. |
FreeMemory() | Clears cached data. |
Dispose() | Frees up memory. |
GetArtifactContent() | The page content marked as artifacts (/Artifact marked-content sequences, PDF 32000-1 §14.8.2.2), in content order: each artifact’s text as runs of one style, with the spaces between words and lines restored, and its images. |
HasVectorGraphics() | Whether this page paints any vector graphics, i.e. |
CalculateContentBBox() | Compute the smallest axis-aligned rectangle in page space enclosing all painted content on this page (text, vector paths, images, inline images, recursively through Form XObjects). |
AddContentStream(contentBytes: byte[]) | Append a content stream to this page. |
PrependContentStream(contentBytes: byte[]) | Prepend content stream bytes before existing page content (for background elements). |
AddContent(contentStreamBytes: byte[]) | Append content stream bytes to this page. |
SetMediaBox(rect: Rectangle) | Set the media box for this page. |
SetCropBox(rect: Rectangle) | Set the crop box for this page. |
SetBleedBox(rect: Rectangle) | Set the bleed box for this page. |
SetTrimBox(rect: Rectangle) | Set the trim box for this page. |
SetArtBox(rect: Rectangle) | Set the art box for this page. |
SetPageSize(width: double, height: double) | Set the page size by updating the MediaBox. |
GetPageRect(considerRotation: bool) | Get the page rectangle, optionally considering the CropBox. |
Resize(targetSize: Aspose.Pdf.PageSize) | Resize this page to targetSize via media-box update. |
AddImage(imageData: byte[], rect: Rectangle, blackWhite: bool) | Add an image to this page at the specified position and size. |
AddImage(imageStream: Stream, rect: Rectangle) | Add an image from a stream to this page at the specified position and size. |
AddImage(imagePath: string, rectangle: Rectangle) | Add an image from a file path; the rectangle bounds the image, which keeps its own aspect ratio centred inside it. |
AddImage(imageStream: Stream, imageRect: Rectangle, bbox: Rectangle) | Add an image placed at imageRect and cropped to bbox: the image fills its rectangle as usual and only the part inside the bounding box shows. |
AddImage(imageStream: Stream, imageRect: Rectangle, bbox: Rectangle, autoAdjustRectangle: bool) | Add an image placed at imageRect and cropped to bbox; autoAdjustRectangle is recorded only. |
AddImage(imageStream: Stream, imageRect: Rectangle, imageWidth: int, imageHeight: int, saveImageProportions: bool) | Add an image with explicit pixel size + proportion flag (bbox defaults to the image rectangle). |
AddImage(imageStream: Stream, imageRect: Rectangle, imageWidth: int, imageHeight: int, saveImageProportions: bool, bbox: Rectangle) | Add an image with explicit pixel size + bbox. |
AddImage(hocr: string, imageStream: Stream, imageRect: Rectangle) | Insert an image and overlay an HOCR (OCR) string as an invisible text layer (text rendering mode 3), so the page shows the image but its recognised text is searchable / copy-pasteable. |
AddImage(hocr: string, imageStream: Stream, imageRect: Rectangle, bbox: Rectangle) | Insert an image and overlay an HOCR (OCR) string as an invisible text layer; bbox is accepted for API compatibility. |
SendTo(device: PageDevice, output: Stream) | Render this page through a PageDevice to a stream. |
SendTo(device: PageDevice, outputFileName: string) | Render this page through a PageDevice to a file. |
AddGraphics(elements: GraphicElementCollection) | Append the given vector elements (typically produced by GraphicsAbsorber) to this page’s content stream, reproducing each element’s geometry in page space. |
AddGraphics(elements: GraphicElementCollection, rectangle: Rectangle) | Append the vector elements that lie inside rectangle; an element is kept in place, never moved or scaled into the rectangle, and one whose box reaches past it is left out (probed: a page’s full-width white bars were dropped while the drawing inside the rectangle was appended unmoved, and an area away from every element appended nothing). |
DeleteGraphics(elementsToDelete: GraphicElementCollection) | Remove the given absorbed elements from their source page: the content is rewritten without the elements’ own operators; text and other non-vector content stays. |
AddTable(table: Table) | Add a table to this page. |
AddGraph(graph: Drawing.Graph) | Add a graph (collection of shapes) to this page. |
AddFloatingBox(box: FloatingBox) | Add a floating box to this page. |
AddExtGState(extGState: Content.ExtGState) | Add an ExtGState dictionary to this page’s resources and return the resource name. |
AddShading(gradient: Aspose.Pdf.Drawing.GradientAxialShading) | Register an axial gradient in this page’s /Resources/Shading and return the resource name, for a caller writing its own content stream: clip to the shape the gradient is to fill and paint it with /Name sh. |
AddPattern(gradient: Aspose.Pdf.Drawing.GradientAxialShading, matrix: Aspose.Pdf.Matrix?) | Register an axial gradient as a shading PATTERN in this page’s Resources/Pattern and return the resource name, for a caller filling a shape with it: /Pattern cs /Name scn, then paint the shape. |
AddLuminositySoftMask(ramp: Aspose.Pdf.Drawing.GradientAxialShading, box: Aspose.Pdf.Rectangle) | Register a LUMINOSITY soft mask that ramps along an axis, and return the ExtGState resource name that puts it in force: paint /Name gs, and every mark that follows is laid down at the opacity the ramp gives its place on the page. |
AddStamp(stamp: ImageStamp) | Apply an image stamp to this page. |
AddStamp(stamp: PdfPageStamp) | Apply a page stamp to this page. |
AddStamp(stamp: Stamp) | Apply stamp to this page through its Put(Page). |
Flatten() | Flattens all annotations into the page’s content stream. |
IsBlank(fillThresholdFactor: double) | Determines whether the page is blank. |