Page

Overview

Page is a class in Aspose.Pdf FOSS for Java.

Represents a single PDF page (ISO 32000-1:2008, §7.7.3.3).

Properties

NameTypeAccessDescription
owningDocumentDocumentReadReturns the document that owns this page, or null if not attached.
mediaBoxRectangleReadReturns the media box for this page (ISO 32000, §7.7.3.3, Table 30).
cropBoxRectangleReadReturns the crop box for this page.
artBoxRectangleReadReturns the art box.
bleedBoxRectangleReadReturns the bleed box.
trimBoxRectangleReadReturns the trim box.
rectRectangleReadReturns the effective rectangle for this page (same as getCropBox).
rotateintReadReturns the page rotation in degrees (0, 90, 180, or 270).
rotationMatrixMatrixReadReturns the page rotation matrix.
resourcesResourcesReadReturns the page resources.
rawContentsCOSBaseReadReturns the raw page content stream COS object, or null if absent.
contentsOperatorCollectionReadReturns the parsed content stream operators (like Aspose’s page.Contents).
syntheticTextFragmentsList<TextFragment>ReadReturns synthetic in-memory text fragments associated with this page.
annotationsAnnotationCollectionReadReturns the typed annotation collection for this page.
cOSDictionaryCOSDictionaryReadReturns the underlying COS dictionary for this page.
backgroundColorReadReturns the page background colour as set by {@link #setBackground(Color)},
or {@code null} if no explicit background has been applied.
numberintReadReturns the 1-based page number (set by PageCollection).
layersjava.util.List<Layer>ReadReturns the list of layers (Optional Content Groups) on this page.
colorTypeColorTypeReadClassifies the dominant colour content of this page —
{@link ColorType#Rgb} if the content has any chromatic colour,
{@link ColorType#Grayscale} if it uses only gray midtones,
{@link ColorType#BlackAndWhite} if every observed colour is solid
black or solid white, or {@link ColorType#Undefined} for an empty /
unreadable content stream.
artifactsArtifactCollectionReadReturns the collection of artifacts found on this page.
paragraphsParagraphsReadReturns the paragraph collection for this page.
pageInfoPageInfoReadReturns the page info (dimensions and margins) for this page.
headerHeaderFooterReadReturns the header for this page, or null if none.
footerHeaderFooterReadReturns the footer for this page, or null if none.
tocInfoTocInfoReadReturns the TOC info for this page, or null.
stampInfoRecordsCOSArrayReadReturns stamp metadata records stored on this page.
blankbooleanReadReturns {@code true} if the page has no visible content (empty or absent content stream).

Methods

SignatureDescription
Page(pageDict: COSDictionary, parser: PDFParser)Creates a Page wrapper around the given page dictionary.
getOwningDocument()DocumentReturns the document that owns this page, or null if not attached.
getMediaBox()RectangleReturns the media box for this page (ISO 32000, §7.7.3.3, Table 30).
getCropBox()RectangleReturns the crop box for this page.
getArtBox()RectangleReturns the art box.
getBleedBox()RectangleReturns the bleed box.
getTrimBox()RectangleReturns the trim box.
getRect()RectangleReturns the effective rectangle for this page (same as getCropBox).
getPageRect(considerRotation: boolean)RectangleReturns the page rectangle, optionally considering rotation.
getRotate()intReturns the page rotation in degrees (0, 90, 180, or 270).
getRotationMatrix()MatrixReturns the page rotation matrix.
getResources()ResourcesReturns the page resources.
getRawContents()COSBaseReturns the raw page content stream COS object, or null if absent.
getContents()OperatorCollectionReturns the parsed content stream operators (like Aspose’s page.Contents).
markContentsDirty()Marks the cached operator collection as dirty, so that the next
{@link #flushContentsIfDirty()} (invoked by {@code Document.save}) will
serialise the current cache back into {@code /Contents}.
flushPageInfoIfNeeded()Propagates the page-level {@link PageInfo} dimensions back to the
page’s {@code /MediaBox} if the user has changed them through
{@link #getPageInfo()}{@code .setWidth(…)} / {@code setHeight(…)} /
{@code setIsLandscape(…)}.
flushContentsIfDirty()
clearContentsCache()Clears the cached operator collection, forcing the next
{@link #getContents()} call to re-parse from {@code /Contents}.
addSyntheticTextFragments(fragments: List<TextFragment>)Registers synthetic in-memory text fragments associated with this page.
getSyntheticTextFragments()List<TextFragment>Returns synthetic in-memory text fragments associated with this page.
getAnnotations()AnnotationCollectionReturns the typed annotation collection for this page.
getCOSDictionary()COSDictionaryReturns the underlying COS dictionary for this page.
getBackground()ColorReturns the page background colour as set by {@link #setBackground(Color)},
or {@code null} if no explicit background has been applied.
setBackground(color: Color)Sets a solid background colour for this page.
getNumber()intReturns the 1-based page number (set by PageCollection).
setNumber(number: int)Sets the 1-based page number.
setMediaBox(rect: Rectangle)Sets the media box for this page (ISO 32000, §7.7.3.3, Table 30).
setCropBox(rect: Rectangle)Sets the crop box for this page (ISO 32000, §14.11.2).
setArtBox(rect: Rectangle)Sets the art box for this page.
setBleedBox(rect: Rectangle)Sets the bleed box for this page.
setTrimBox(rect: Rectangle)Sets the trim box for this page.
setRotation(degrees: int)Sets the page rotation in degrees.
setRotate(rotation: Rotation)Sets the page rotation using the {@link Rotation} enum.
accept(absorber: TextAbsorber)Accepts a text absorber to extract text from this page.
accept(absorber: ImagePlacementAbsorber)Accepts an image placement absorber to find images on this page.
getLayers()java.util.List<Layer>Returns the list of layers (Optional Content Groups) on this page.
setLayers(layers: java.util.List<Layer>)Sets the layers for this page.
getColorType()ColorTypeClassifies the dominant colour content of this page —
{@link ColorType#Rgb} if the content has any chromatic colour,
{@link ColorType#Grayscale} if it uses only gray midtones,
{@link ColorType#BlackAndWhite} if every observed colour is solid
black or solid white, or {@link ColorType#Undefined} for an empty /
unreadable content stream.
getArtifacts()ArtifactCollectionReturns the collection of artifacts found on this page.
add(artifact: Artifact)
setPageSize(width: double, height: double)Convenience method to set the page size by setting the media box.
getParagraphs()ParagraphsReturns the paragraph collection for this page.
setParagraphs(paragraphs: Paragraphs)Sets the paragraph collection for this page.
getPageInfo()PageInfoReturns the page info (dimensions and margins) for this page.
setPageInfo(pageInfo: PageInfo)Sets the page info.
getHeader()HeaderFooterReturns the header for this page, or null if none.
setHeader(header: HeaderFooter)Sets the header for this page.
getFooter()HeaderFooterReturns the footer for this page, or null if none.
setFooter(footer: HeaderFooter)Sets the footer for this page.
getTocInfo()TocInfoReturns the TOC info for this page, or null.
setTocInfo(tocInfo: TocInfo)Sets the TOC info, making this page a table-of-contents page.
flattenAnnotations()Flattens all annotations on this page by baking their normal appearance
streams into the page content stream, then removing the /Annots entry
(ISO 32000-1:2008, §12.5.5).
addStamp(stamp: Stamp)Adds a stamp to this page by delegating to the stamp’s {@link Stamp#put(Page)} method.
addStamp(stamp: TextStamp)Adds a text stamp to this page by generating content stream operators.
addStamp(stamp: ImageStamp)Adds an image stamp to this page by generating content stream operators.
addStamp(stamp: PdfPageStamp)Adds a page stamp to this page by overlaying the source page content.
getStampInfoRecords()COSArrayReturns stamp metadata records stored on this page.
removeStampById(stampId: int)boolean
prependToContentStream(data: byte[])Prepends raw content stream data before this page’s existing /Contents.
appendToContentStream(data: byte[])Appends raw content stream data to this page’s /Contents.
ensureResources()ResourcesEnsures this page has a /Resources dictionary, creating one if absent.
setContents(operators: OperatorCollection)Replaces the page content stream with the given operator collection.
isBlank()booleanReturns {@code true} if the page has no visible content (empty or absent content stream).
replaceText(searchText: String, replaceText: String)intReplaces all occurrences of {@code searchText} with {@code replaceText}
in this page’s content stream.

See Also