Inheritance: java.lang.Object, com.aspose.pdf.Page

All Implemented Interfaces: com.aspose.ms.System.IDisposable, com.aspose.pdf.engine.IOperatorContainer, Closeable, AutoCloseable

public final class Page extends Object implements com.aspose.ms.System.IDisposable, Closeable , com.aspose.pdf.engine.IOperatorContainer

Class representing page of PDF document.

Methods

MethodDescription
acceptAccepts {@code AnnotationSelector} visitor object that provides functionality to work with annotations.
acceptAccepts {@code ImagePlacementAbsorber} visitor object that provides functionality to work with image placement objects.
acceptAccepts {@code TextAbsorber} visitor object that provides functionality to work with text objects.
acceptAccepts {@code TextFragmentAbsorber} visitor object that provides functionality to work with text objects.
addGraphicsAdds graphics to the page. Works faster than adding elements one by one with GraphicElement#addOnPage(Page) method.
addGraphicsAdds graphics to the page. Works faster than adding elements one by one with GraphicElement#addOnPage(Page) method.
addImageAdds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addImageAdds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.
addStampPut stamp into page. Stamp can be page number, image or simple text, e.g. some logo.
asByteArrayConverts current page as BMP bitmap and than returns array of bytes.
asXmlConverts current page as xml in utf8 encoding.
calculateContentBBoxCalculates bbox value - rectangle containing contents without visible margins.
clearContentsFor internal usage only
closeCloses all resources used by this document.
convertToPNGMemoryStreamConvert page to PNG for DSR, OMR, OCR image stream.
deleteGraphicsDeletes graphics from the page. Works faster than deleting elements one by one with {@link GraphicElement#remove} method.
deleteUnusedResources
disposeFrees up memory This method is obsolete, use close() instead.
fillUsedObjectsTable
findReferencesReturns list of operators which uses resource with specified name.
findReferences

Find references

flattenRemoves all static fields located on the page and place their values instead.
freeMemoryClears cached data
getActionsGets collection of page properties.
getAnnotationsGets collection of page annotations. {@code Annotations}
getArtBox

Gets art box of the page.

getArtifactsGets collection of artifacts on the page.
getBackgroundGets the background color of the page.
getBackgroundImageGets or sets background image for page (for generator only, not filled in when reading document).
getBleedBox

Gets bleed box of the page.

getColorTypeGets color type of the pages based on information getting from operators SetColor, images and forms.
getContents

Gets collection of operators in the content stream of the page. {@code OperatorCollection}

getContentsAppenderGets current contents appender. {@code ContentsAppender}
getCropBox

Gets crop box of the page.

getDocumentGet document
getDuration

Gets page display duration. This is time in seconds that page shall be displayed during presentation. Returns -1 if duration is not defined.


Example demonstrates how to get page duration

Document document = new Document(“sample.pdf”); Page page = document.getPages().get(1); int pageRect = page.getDuration();

getEnginePageFor Internal usage only
getFieldsInTabOrderGets list of Field object in Tab order on this page.
getFooterGets page Footer.
getGroupGets a group attributes class specifying the attributes of the page’s page group for use in the transparent imaging model.
getHeaderGets page header.
getLayersGets layers collection.
getMediaBox

Gets media box of the page.

getNoteLineStyleGets the line style for notes.(for generator only, not filled in when reading document)
getNotificationsReturns notifications about inside operations with page content. (Only notifications about paragraph events in text adding scenarios are supported now.)
getNumberGet number of the page.
getOnBeforePageGenerateEvent for customize header and footer.
getPageInfoGets the page info.(for generator only, not filled in when reading document).
getPageRectReturns rectangle of the page according to its CropBox (or MediaBox if CropBox null).
getParagraphsGets the paragraphs.
getRect_Rename_Namesake

Returns rectangle of the page according to its CropBox and MediaBox;

Internal
getRect

Returns rectangle of the page according to its CropBox and MediaBox; For get: page crop box is returned if specified, otherwise page media box is returned. For set: page media box always set.

getResourcesRetrieves the resources associated with the page.
getResourcesField

Gets page resources. Resources object contains collections of images, forms and fonts. {@code Resources}

getRotate

Gets rotation of the page.

getRotationMatrixGets transformation matrix for the page.
getTabOrderGets tab order of the page. Possible values: Row, Column. Default, Manual
getTocInfoGets table of contents info.
getTrimBox

Gets trim box of the page.

getUserUnitGets or sets UserUnit value. A positive number giving the size of default user space units, in multiples of 1 / 72 inch. Default value is 1. Please set zero or negative value in order to clear this entry in page.
getWatermarkGets the watermark of the page.
hasVectorGraphicsDetect of the presence of vector graphics, if it is present on the page.
intToRotationTranslates integer value into corresponding rotation enumeration member.
isAddParagraphsAfterLastGets or sets the addition of paragraphs after the last paragraph of the page Value: Value indicates whether paragraphs will be added after the last paragraph of the page. Paragraphs will be added after the last paragraph of the page if value is true.
isBlankGets the flag whether page is blank or not.
isBlankGets the flag whether page is blank or not.
makeGrayscaleConverts the page to grayscale.
mergeLayersMerges all layers on the page into a single layer with the specified new layer name.
mergeLayersMerges all layers on the page into a single layer with the specified new layer name and optional content group Id.
removeObjectReferencesRemove object references
removeObjectReferencesRemove references to XObject from page contents (i.e. all Do operators which use name of object).
resizeResizes the page.
rotationToIntTranslates rotation enumeration member into integer value.
sendToSends page to process with given page device.
sendToSends page to process with given page device.
setAddParagraphsAfterLastGets or sets the addition of paragraphs after the last paragraph of the page Value: Value indicates whether paragraphs will be added after the last paragraph of the page. Paragraphs will be added after the last paragraph of the page if value is true.
setArtBoxSets art box of the page.
setBackgroundSets the background color of the page.
setBackgroundSets the background color of the page.
setBackgroundImageGets or sets background image for page (for generator only, not filled in when reading document).
setBleedBoxSets bleed box of the page.
setCropBox

Sets crop box of the page.


 Example demonstrates how to get crop box of the page: Document document = new Document(“sample.pdf”); document.getPages().get_Item(1).setCropBox(new Rectangle(0d,0d,100d,100d)); 
setDurationSets page display duration. This is time in seconds that page shall be displayed during presentation. Returns -1 if duration is not defined.
setEnginePageFor Internal usage only
setFooterSets page Footer.
setGroupSets a group attributes class specifying the attributes of the page’s page group for use in the transparent imaging model.
setHeaderSets page header.
setLayersSets layers collection.
setLayersInternalSets layers collection.
setMediaBoxSets media box of the page.
setNoteLineStyleSets the line style for notes.(for generator only, not filled in when reading document)
setPageInfoSets the page info.(for generator only, not filled in when reading document).
setPageSizeSets page size for page.
setParagraphsSets the paragraphs.
setRectGets or sets rectangle of the page. For get: page crop box is returned if specified, otherwise page media box is returned. For set: page media box always set. is returned. Please note that this property don’t consider page rotation. To get page rectangle considering rotation please use ActualRect.
setRotateSets rotation of the page.
setTabOrderSets tab order of the page. Possible values: Row, Column. Default, Manual
setTocInfoSets table of contents info.
setTransitionSet transition
setTrimBoxSets trim box of the page.
setUserUnitGets or sets UserUnit value. A positive number giving the size of default user space units, in multiples of 1 / 72 inch. Default value is 1. Please set zero or negative value in order to clear this entry in page.
setWatermarkSets the watermark of the page.
trySaveVectorGraphicsTries to save vector graphics if they are present on the page. The save format is SVG.

accept

Accepts {@code AnnotationSelector} visitor object that provides functionality to work with annotations.

accept

Accepts {@code ImagePlacementAbsorber} visitor object that provides functionality to work with image placement objects.

accept

Accepts {@code TextAbsorber} visitor object that provides functionality to work with text objects.

accept

Accepts {@code TextFragmentAbsorber} visitor object that provides functionality to work with text objects.

addGraphics

Adds graphics to the page. Works faster than adding elements one by one with GraphicElement#addOnPage(Page) method.

addGraphics

Adds graphics to the page. Works faster than adding elements one by one with GraphicElement#addOnPage(Page) method.

addImage

Adds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds searchable image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addImage

Adds image onto the page and locates it in the middle of specified rectangle saving image’s proportion.

addStamp

Put stamp into page. Stamp can be page number, image or simple text, e.g. some logo.

asByteArray

Converts current page as BMP bitmap and than returns array of bytes.

asXml

public String asXml()

Converts current page as xml in utf8 encoding.

Returns: Converted xml string.

calculateContentBBox

public Rectangle calculateContentBBox()

Calculates bbox value - rectangle containing contents without visible margins.

Returns: Bbox value - rectangle containing contents without visible margins

clearContents

public void clearContents()

For internal usage only

close

public void close()

Closes all resources used by this document.

convertToPNGMemoryStream

public byte[] convertToPNGMemoryStream()

Convert page to PNG for DSR, OMR, OCR image stream.

Returns: Image stream in byte[] array.

deleteGraphics

Deletes graphics from the page. Works faster than deleting elements one by one with {@link GraphicElement#remove} method.

deleteUnusedResources

dispose

@Deprecated public void dispose()

Frees up memory This method is obsolete, use close() instead.

fillUsedObjectsTable

findReferences

Returns list of operators which uses resource with specified name.

findReferences

Find references

flatten

public void flatten()

Removes all static fields located on the page and place their values instead.

freeMemory

public void freeMemory()

Clears cached data

getActions

public PageActionCollection getActions()

Gets collection of page properties.

Returns: PageActionCollection value

getAnnotations

public AnnotationCollection getAnnotations()

Gets collection of page annotations. {@code Annotations}

Returns: AnnotationCollection value

getArtBox

public Rectangle getArtBox()

Gets art box of the page.

Returns: Rectangle value


 Example demonstrates how to get art box of the page: Document document = new Document(“sample.pdf”); Rectangle artBox = document.getPages().get(1).getArtBox(); 

getArtifacts

public ArtifactCollection getArtifacts()

Gets collection of artifacts on the page.

Returns: ArtifactCollection value

getBackground

public Color getBackground()

Gets the background color of the page.

Returns: Color value

getBackgroundImage

public final Image getBackgroundImage()

Gets or sets background image for page (for generator only, not filled in when reading document).

Returns: Image instance

getBleedBox

public Rectangle getBleedBox()

Gets bleed box of the page.

Returns: Rectangle value


 Example demonstrates how to get bleed box of the page: Document document = new Document(“sample.pdf”); Rectangle bleedBox = document.getPages().get(1).getBleedBox(); 

getColorType

public ColorType getColorType()

Gets color type of the pages based on information getting from operators SetColor, images and forms.

Returns: ColorType element @see ColorType

getContents

public OperatorCollection getContents()

Gets collection of operators in the content stream of the page. {@code OperatorCollection}

Returns: OperatorCollection object


 Example is demonstrates how to scan operators stream of page. Document document = new Document(“sample.pdf”); Operators contents = document.getPages().get_Item(1).getContents(); for(Operator op : {@code (Iterable)}contents) { System.out.println(op); } 

getContentsAppender

public ContentsAppender getContentsAppender()

Gets current contents appender. {@code ContentsAppender}

Returns: ContentsAppender value

getCropBox

public Rectangle getCropBox()

Gets crop box of the page.

Returns: Rectangle value


 Example demonstrates how to get crop box of the page: Document document = new Document(“sample.pdf”); Rectangle cropBox = document.getPages().get_Item(1).getCropBox(); 

getDocument

public IDocument getDocument()

Get document

Returns: IDocument object

getDuration

public double getDuration()

Gets page display duration. This is time in seconds that page shall be displayed during presentation. Returns -1 if duration is not defined.


Example demonstrates how to get page duration

Document document = new Document("sample.pdf"); Page page = document.getPages().get(1); int pageRect = page.getDuration();

Returns: double value

getEnginePage

public com.aspose.pdf.engine.commondata.IPage getEnginePage()

For Internal usage only

Returns: internal instance

getFieldsInTabOrder

public List < Field > getFieldsInTabOrder()

Gets list of Field object in Tab order on this page.

Returns: List of field objects

getFooter

public HeaderFooter getFooter()

Gets page Footer.

Returns: The page Footer.

getGroup

public Group getGroup()

Gets a group attributes class specifying the attributes of the page’s page group for use in the transparent imaging model.

Returns: Group value

getHeader

public HeaderFooter getHeader()

Gets page header.

Returns: The page header.

getLayers

public List < Layer > getLayers()

Gets layers collection.

Returns: Value: The layers’ collection.

getMediaBox

public Rectangle getMediaBox()

Gets media box of the page.

Returns: Rectangle value


 Example demonstrates how to get media box of the page: Document document = new Document(“sample.pdf”); Rectangle mediaBox = document.getPages().get(1).getMediaBox(); 

getNoteLineStyle

public GraphInfo getNoteLineStyle()

Gets the line style for notes.(for generator only, not filled in when reading document)

Returns: GraphInfo value

getNotifications

public String getNotifications()

Returns notifications about inside operations with page content. (Only notifications about paragraph events in text adding scenarios are supported now.)

Returns: String representing notifications about inside operations with page content.

getNumber

public final int getNumber()

Get number of the page.

Returns: int value

getOnBeforePageGenerate

public PdfEvent < Page.BeforePageGenerate > getOnBeforePageGenerate()

Event for customize header and footer.

Returns: {@code PdfEvent instance}

getPageInfo

public PageInfo getPageInfo()

Gets the page info.(for generator only, not filled in when reading document).

Returns: The page info.

getPageRect

public Rectangle getPageRect(boolean considerRotation)

Returns rectangle of the page according to its CropBox (or MediaBox if CropBox null).

Parameters:

ParameterTypeDescription
considerRotationIf true then rotation of the page will be considered in rect calculation.

Returns: Rectangle of the page.

getParagraphs

public Paragraphs getParagraphs()

Gets the paragraphs.

Returns: The paragraphs.

getRect_Rename_Namesake

public Rectangle getRect_Rename_Namesake()

Returns rectangle of the page according to its CropBox and MediaBox;

Internal

Returns: Rectangle value


 Example demonstrates how to get page rectangle: Document document = new Document(“sample.pdf”); Page page = document.getPages().get(1); Rectangle pageRect = page.getRect(); 

getRect

public Rectangle getRect()

Returns rectangle of the page according to its CropBox and MediaBox; For get: page crop box is returned if specified, otherwise page media box is returned. For set: page media box always set.

Returns: Rectangle value


 Example demonstrates how to get page rectangle: Document document = new Document(“sample.pdf”); Page page = document.getPages().get(1); Rectangle pageRect = page.getRect(); 

getResources

public final Resources getResources()

Retrieves the resources associated with the page.

Returns: A {@code Resources}({@link #getResources()}) object representing the resources of the page.

getResourcesField

public Resources getResourcesField()

Gets page resources. Resources object contains collections of images, forms and fonts. {@code Resources}

Returns: Resources value


 Example demonstrates scan through page images: Document document = new Document(“sample.pdf”); DocumentActions actions = document.getActions(); Resources resources = document.getPages().get(1).getResources(); for(XImage image : {@code (Iterable)resources}.getImages()) { System.out.println(image.getWidth() + “:” + image.getHeight()); } 

getRotate

public Rotation getRotate()

Gets rotation of the page.

Returns: Rotation element


 Example demonstrates how to determine page rotation. Document document = new Document(“sample.pdf”); System.out.println(document.getPages().get(1).getRotate()); 
@see Rotation

getRotationMatrix

public Matrix getRotationMatrix()

Gets transformation matrix for the page.

Returns: Matrix value

getTabOrder

public int getTabOrder()

Gets tab order of the page. Possible values: Row, Column. Default, Manual

Returns: TabOrder value @see TabOrder

getTocInfo

public TocInfo getTocInfo()

Gets table of contents info.

Returns: The table of contents info - default null. If it set this page will contain table of contents.

getTrimBox

public Rectangle getTrimBox()

Gets trim box of the page.

Returns: Rectangle value


 Example demonstrates how to get trim box of the page: Document document = new Document(“sample.pdf”); Rectangle trimBox = document.getPages().get(1).getTrimBox(); 

getUserUnit

public final double getUserUnit()

Gets or sets UserUnit value. A positive number giving the size of default user space units, in multiples of 1 / 72 inch. Default value is 1. Please set zero or negative value in order to clear this entry in page.

Returns: double value

getWatermark

public Watermark getWatermark()

Gets the watermark of the page.

Returns: Watermark value

hasVectorGraphics

public final boolean hasVectorGraphics()

Detect of the presence of vector graphics, if it is present on the page.

Returns: True if the page contains path construction operators; otherwise, False.

intToRotation

public static Rotation intToRotation(int rotation)

Translates integer value into corresponding rotation enumeration member.

Parameters:

ParameterTypeDescription
rotationInteger value to convert

Returns: Rotation enumeration member @see Rotation

isAddParagraphsAfterLast

public final boolean isAddParagraphsAfterLast()

Gets or sets the addition of paragraphs after the last paragraph of the page Value: Value indicates whether paragraphs will be added after the last paragraph of the page. Paragraphs will be added after the last paragraph of the page if value is true.

Returns: boolean value

isBlank

public boolean isBlank(double fillThresholdFactor)

Gets the flag whether page is blank or not.

Parameters:

ParameterTypeDescription
fillThresholdFactorThe fill threshold value that manages the sensitivity of detection. Should be in range [0..1). To determine whether a page is empty or not, the ratio of the filled space to the total space of the page is calculated. This ratio is compared with the fillThresholdFactor parameter and if it is less, the page is considered empty.

Returns: boolean value True - if page is blank; otherwise, false.

isBlank

public boolean isBlank(double fillThresholdFactor, boolean parseWhiteContent)

Gets the flag whether page is blank or not.

Parameters:

ParameterTypeDescription
fillThresholdFactorThe fill threshold value that manages the sensitivity of detection. Should be equal or greater than 0.01.
parseWhiteContentTrue for complete page scanning with white contend analyzing, False (default) - fast algorithm, where white graphics is counted as not blank page.

Returns: boolean value True - if page is blank; otherwise, false.

makeGrayscale

public final void makeGrayscale()

Converts the page to grayscale.

mergeLayers

Merges all layers on the page into a single layer with the specified new layer name.

mergeLayers

Merges all layers on the page into a single layer with the specified new layer name and optional content group Id.

removeObjectReferences

Remove object references

removeObjectReferences

Remove references to XObject from page contents (i.e. all Do operators which use name of object).

resize

Resizes the page.

rotationToInt

Translates rotation enumeration member into integer value.

sendTo

Sends page to process with given page device.

sendTo

Sends page to process with given page device.

setAddParagraphsAfterLast

public final void setAddParagraphsAfterLast(boolean value)

Gets or sets the addition of paragraphs after the last paragraph of the page Value: Value indicates whether paragraphs will be added after the last paragraph of the page. Paragraphs will be added after the last paragraph of the page if value is true.

Parameters:

ParameterTypeDescription
valueboolean value

setArtBox

Sets art box of the page.

setBackground

Sets the background color of the page.

setBackground

Sets the background color of the page.

setBackgroundImage

Gets or sets background image for page (for generator only, not filled in when reading document).

setBleedBox

Sets bleed box of the page.

setCropBox

Sets crop box of the page.


 Example demonstrates how to get crop box of the page: Document document = new Document("sample.pdf"); document.getPages().get_Item(1).setCropBox(new Rectangle(0d,0d,100d,100d)); 

setDuration

public void setDuration(double value)

Sets page display duration. This is time in seconds that page shall be displayed during presentation. Returns -1 if duration is not defined.

Parameters:

ParameterTypeDescription
valuepage display duration.

setEnginePage

For Internal usage only

setFooter

Sets page Footer.

setGroup

Sets a group attributes class specifying the attributes of the page’s page group for use in the transparent imaging model.

setHeader

Sets page header.

setLayers

Sets layers collection.

setLayersInternal

Sets layers collection.

setMediaBox

Sets media box of the page.

setNoteLineStyle

Sets the line style for notes.(for generator only, not filled in when reading document)

setPageInfo

Sets the page info.(for generator only, not filled in when reading document).

setPageSize

public void setPageSize(double width, double height)

Sets page size for page.

Parameters:

ParameterTypeDescription
widthPage width.
heightPage size.

setParagraphs

Sets the paragraphs.

setRect

Gets or sets rectangle of the page. For get: page crop box is returned if specified, otherwise page media box is returned. For set: page media box always set. is returned. Please note that this property don’t consider page rotation. To get page rectangle considering rotation please use ActualRect.

setRotate

Sets rotation of the page.

setTabOrder

public void setTabOrder(int value)

Sets tab order of the page. Possible values: Row, Column. Default, Manual

Parameters:

ParameterTypeDescription
valueTabOrder object @see TabOrder

setTocInfo

Sets table of contents info.

setTransition

Set transition

setTrimBox

Sets trim box of the page.

setUserUnit

public final void setUserUnit(double value)

Gets or sets UserUnit value. A positive number giving the size of default user space units, in multiples of 1 / 72 inch. Default value is 1. Please set zero or negative value in order to clear this entry in page.

Parameters:

ParameterTypeDescription
valuedouble value

setWatermark

Sets the watermark of the page.

trySaveVectorGraphics

Tries to save vector graphics if they are present on the page. The save format is SVG.