Page
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
| Method | Description |
|---|---|
| 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 | Converts current page as xml in utf8 encoding. |
| calculateContentBBox | Calculates bbox value - rectangle containing contents without visible margins. |
| clearContents | For internal usage only |
| close | Closes all resources used by this document. |
| convertToPNGMemoryStream | Convert page to PNG for DSR, OMR, OCR image stream. |
| deleteGraphics | Deletes graphics from the page. Works faster than deleting elements one by one with {@link GraphicElement#remove} method. |
| deleteUnusedResources | |
| 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 | Removes all static fields located on the page and place their values instead. |
| freeMemory | Clears cached data |
| getActions | Gets collection of page properties. |
| getAnnotations | Gets collection of page annotations. {@code Annotations} |
| getArtBox | Gets art box of the page. |
| getArtifacts | Gets collection of artifacts on the page. |
| getBackground | Gets the background color of the page. |
| getBackgroundImage | Gets or sets background image for page (for generator only, not filled in when reading document). |
| getBleedBox | Gets bleed box of the page. |
| getColorType | Gets 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} |
| getContentsAppender | Gets current contents appender. {@code ContentsAppender} |
| getCropBox | Gets crop box of the page. |
| getDocument | Get 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(); |
| getEnginePage | For Internal usage only |
| getFieldsInTabOrder | Gets list of Field object in Tab order on this page. |
| getFooter | Gets page Footer. |
| getGroup | Gets a group attributes class specifying the attributes of the page’s page group for use in the transparent imaging model. |
| getHeader | Gets page header. |
| getLayers | Gets layers collection. |
| getMediaBox | Gets media box of the page. |
| getNoteLineStyle | Gets the line style for notes.(for generator only, not filled in when reading document) |
| getNotifications | Returns notifications about inside operations with page content. (Only notifications about paragraph events in text adding scenarios are supported now.) |
| getNumber | Get number of the page. |
| getOnBeforePageGenerate | Event for customize header and footer. |
| getPageInfo | Gets the page info.(for generator only, not filled in when reading document). |
| getPageRect | Returns rectangle of the page according to its CropBox (or MediaBox if CropBox null). |
| getParagraphs | Gets 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. |
| getResources | Retrieves 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. |
| getRotationMatrix | Gets transformation matrix for the page. |
| getTabOrder | Gets tab order of the page. Possible values: Row, Column. Default, Manual |
| getTocInfo | Gets table of contents info. |
| getTrimBox | Gets trim box of the page. |
| 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. |
| getWatermark | Gets the watermark of the page. |
| hasVectorGraphics | Detect of the presence of vector graphics, if it is present on the page. |
| intToRotation | Translates integer value into corresponding rotation enumeration member. |
| 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. |
| isBlank | Gets the flag whether page is blank or not. |
| isBlank | Gets the flag whether page is blank or not. |
| 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 | 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. |
| 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 | Sets page display duration. This is time in seconds that page shall be displayed during presentation. Returns -1 if duration is not defined. |
| 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 | Sets page size for page. |
| 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 | Sets tab order of the page. Possible values: Row, Column. Default, Manual |
| setTocInfo | Sets table of contents info. |
| setTransition | Set transition |
| setTrimBox | Sets trim box of the page. |
| setUserUnit | 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. |
| 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. |
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
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:
| Parameter | Type | Description |
|---|---|---|
| considerRotation | If 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;
InternalReturns: 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:
| Parameter | Type | Description |
|---|---|---|
| rotation | Integer 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:
| Parameter | Type | Description |
|---|---|---|
| fillThresholdFactor | The 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:
| Parameter | Type | Description |
|---|---|---|
| fillThresholdFactor | The fill threshold value that manages the sensitivity of detection. Should be equal or greater than 0.01. | |
| parseWhiteContent | True 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:
| Parameter | Type | Description |
|---|---|---|
| value | boolean 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:
| Parameter | Type | Description |
|---|---|---|
| value | page 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:
| Parameter | Type | Description |
|---|---|---|
| width | Page width. | |
| height | Page 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:
| Parameter | Type | Description |
|---|---|---|
| value | TabOrder 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:
| Parameter | Type | Description |
|---|---|---|
| value | double 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.