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

NameTypeAccessDescription
NumberintRead1-based page number.
FieldsInTabOrderIList<Forms.Field>ReadForm fields whose widgets appear on this page, ordered by their tab order.
RectRectangleRead/WritePage rectangle (defaults to MediaBox).
RectangleRectangleRead/WriteThe page rectangle.
PageInfoPageInfoRead/WritePage info container with width/height/margin properties.
BackgroundColor?Read/WritePage background colour.
MediaBoxRectangleRead/WriteThe media box for this page (required per spec).
CropBoxRectangleRead/WriteThe crop box (defaults to media box).
BleedBoxRectangleRead/WriteThe bleed box (defaults to crop box).
TrimBoxRectangleRead/WriteThe trim box (defaults to crop box).
ArtBoxRectangleRead/WriteThe art box (defaults to crop box).
RotateRotationRead/WritePage rotation as Rotation enum.
RotateDegreesintRead/WritePage rotation in degrees as int (0, 90, 180, 270).
RotationMatrixMatrixReadAffine transform that maps the unrotated PDF coordinate system to the page’s user-visible (rotated) one.
DurationdoubleRead/WritePage display duration in seconds for presentation mode.
AnnotationsAnnotationCollectionReadAnnotations on this page.
ResourcesResourcesReadPage resources (fonts, images) — provides access via a unified Resources object.
PatternsIReadOnlyDictionary<string, Pattern>ReadPattern resources on this page (keyed by pattern name).
WidthdoubleReadVisible page width accounting for rotation.
HeightdoubleReadVisible page height accounting for rotation.
ColorTypeColorTypeReadGets the color type of this page by analyzing its content stream operators and image color spaces.
TransitionPageTransition?ReadThe page transition effect, or null if none is set.
HeaderHeaderFooter?Read/WriteHeader to render at the top of this page.
FooterHeaderFooter?Read/WriteFooter to render at the bottom of this page.
TocInfoTocInfo?Read/WriteTOC information for this page.
ColumnInfoColumnInfo?Read/WriteThe 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.
ParagraphsParagraphsRead/WriteCollection of paragraph objects to add to this page (TextFragment, HtmlFragment, Table, Heading, etc.).
NoteLineStyleGraphInfoRead/WriteDefault stroke/fill style used to draw footnote / endnote separator lines.
ArtifactsArtifactCollectionReadCollection for adding artifacts (watermarks, etc.) to this page.
OcgLayersLayerCollectionReadGets the layers (Optional Content Groups) referenced by this page.
ActionsPageActionCollectionReadPer-page additional actions (open / close / etc.), backed by /AA.
UserUnitdoubleRead/WriteUser-unit factor (PDF 32000 §14.8.4 /UserUnit entry).
IsAddParagraphsAfterLastboolRead/WriteWhether Paragraphs additions append at the end (vs flow position).
GroupGroup?Read/WriteGroup / blending colour space dictionary for this page.
TabOrderTabOrderRead/WriteTab order (PDF 32000 §12.5 /Tabs entry).
WatermarkWatermark?Read/WriteThe page watermark.
ContentsOperatorCollectionReadContent stream operator collection.
ContentsAppenderContentsAppenderReadHelper that buffers operators to prepend to / append to this page’s content stream, applied on UpdateData.
ImagesXImageCollectionReadImage XObjects on this page.
BackgroundImageImage?Read/WritePage background image.
LayersSystem.Collections.Generic.List<Layer>Read/WriteThe page’s layers (Optional Content Groups).
FontsFontCollectionReadFonts referenced by this page.

Methods

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

See Also

 English