public final class Page extends Object implements com.aspose.ms.System.IDisposable
Class representing page of PDF document.
Modifier and Type | Class and Description |
---|---|
static class |
Page.BeforePageGenerate
Procedure for customize header and footer.
|
Modifier and Type | Field and Description |
---|---|
com.aspose.pdf.engine.commondata.IPage |
EnginePage
For Internal usage only
|
PdfEvent<Page.BeforePageGenerate> |
OnBeforePageGenerate
Event for customize header and footer.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(AnnotationSelector visitor)
Accepts
AnnotationSelector visitor object that provides functionality to work with
annotations. |
void |
accept(ImagePlacementAbsorber visitor)
Accepts
ImagePlacementAbsorber visitor object that provides functionality to work
with image placement objects. |
void |
accept(TextAbsorber visitor)
Accepts
TextAbsorber visitor object that provides functionality to work with text
objects. |
void |
accept(TextFragmentAbsorber visitor)
Accepts
TextFragmentAbsorber visitor object that provides functionality to work with
text objects. |
void |
addImage(InputStream imageStream,
Rectangle imageRect)
Adds image onto the page and locates it in the middle of specified rectangle saving image's
proportion.
|
void |
addImage(InputStream stream,
Rectangle rectangle,
CompositingParameters compositingParameters)
Adds image onto the page and locates it in the middle of specified rectangle saving image's
proportion.
|
void |
addImage(InputStream imageStream,
Rectangle imageRect,
int imageWidth,
int imageHeight,
boolean saveImageProportions)
Adds searchable image onto the page and locates it in the middle of specified rectangle
saving image's proportion.
|
void |
addImage(String hocr,
InputStream imageStream,
Rectangle imageRect)
Adds searchable image onto the page and locates it in the middle of specified rectangle
saving image's proportion.
|
void |
addImage(String imagePath,
Rectangle rectangle)
Adds image onto the page and locates it in the middle of specified rectangle saving image's
proportion.
|
void |
addStamp(Stamp stamp)
Put stamp into page.
|
byte[] |
asByteArray(Resolution resolution)
Converts current page as BMP bitmap and than returns array of bytes.
|
String |
asXml()
Converts current page as xml in utf8 encoding.
|
Rectangle |
calculateContentBBox()
Calculates bbox value - rectangle containing contents without visible margins.
|
void |
clearContents()
For internal usage only
|
byte[] |
convertToPNGMemoryStream()
Convert page to PNG for DSR, OMR , OCR
|
void |
deleteUnusedResources(com.aspose.ms.System.Collections.Generic.Dictionary<Integer,Integer> usageTable) |
void |
dispose()
Frees up memory
|
void |
fillUsedObjectsTable(com.aspose.ms.System.Collections.Generic.Dictionary<Integer,Integer> usageTable,
com.aspose.pdf.engine.data.IPdfDictionary CommonResources) |
static List<Object> |
findReferences(OperatorCollection contents,
String name)
Returns list of operators which uses resource with specified name.
|
List<Object> |
findReferences(String name)
Find references
|
void |
flatten()
Removes all static fields located on the page and place their values instead.
|
void |
freeMemory()
Clears cached data
|
PageActionCollection |
getActions()
Gets collection of page properties.
|
AnnotationCollection |
getAnnotations()
Gets collection of page annotations.
|
Rectangle |
getArtBox()
Gets art box of the page.
|
ArtifactCollection |
getArtifacts()
Gets collection of artifacts on the page.
|
Color |
getBackground()
Gets the background color of the page.
|
Image |
getBackgroundImage()
Gets or sets background image for page (for generator only).
|
Rectangle |
getBleedBox()
Gets bleed box of the page.
|
int |
getColorType()
Gets color type of the pages based on information getting from operators SetColor, images and
forms.
|
OperatorCollection |
getContents()
Gets collection of operators in the content stream of the page.
|
ContentsAppender |
getContentsAppender()
Gets current contents appender.
|
Rectangle |
getCropBox()
Gets crop box of the page.
|
IDocument |
getDocument()
Get document
|
double |
getDuration()
Gets page display duration.
|
List<Field> |
getFieldsInTabOrder()
Gets list of Field object in Tab order on this page.
|
HeaderFooter |
getFooter()
Gets page Footer.
|
Group |
getGroup()
Gets a group attributes class specifying the attributes of the page's page group for use in
the transparent imaging model.
|
HeaderFooter |
getHeader()
Gets page header.
|
List<Layer> |
getLayers()
Gets layers collection.
|
Rectangle |
getMediaBox()
Gets media box of the page.
|
GraphInfo |
getNoteLineStyle()
Gets the line style for notes.
|
String |
getNotifications()
Returns notifications about inside operations with page content.
|
int |
getNumber()
Get number of the page.
|
PageInfo |
getPageInfo()
Gets the page info.
|
Rectangle |
getPageRect(boolean considerRotation)
Returns rectangle of the page.
|
Paragraphs |
getParagraphs()
Gets the paragraphs.
|
Rectangle |
getRect_Rename_Namesake()
Gets rectangle of the page.
|
Rectangle |
getRect()
Gets rectangle of the page.
|
Resources |
getResources()
Gets page resources.
|
int |
getRotate()
Gets rotation of the page.
|
Matrix |
getRotationMatrix()
Gets transfomation matrix for the page.
|
int |
getTabOrder()
Gets tab order of the page.
|
TocInfo |
getTocInfo()
Gets table of contents info.
|
Rectangle |
getTrimBox()
Gets trim box of the page.
|
Watermark |
getWatermark()
Gets the watermark of the page.
|
static int |
intToRotation(int rotation)
Translates integer value into corresponding rotation enumeration member.
|
boolean |
isBlank(double fillThresholdFactor)
Gets the flag whether page is blank or not.
|
void |
makeGrayscale()
Converts images on page as grayscaled.
|
static void |
removeObjectReferences(OperatorCollection contents,
String name)
Remove object references
|
void |
removeObjectReferences(String name)
Remove references to XObject from page contents (i.e. all Do operators which use name of
object).
|
static int |
rotationToInt(int rotation)
Translates rotation enumeration member into integer value.
|
void |
sendTo(PageDevice device,
OutputStream output)
Sends page to process with given page device.
|
void |
sendTo(PageDevice device,
String outputFileName)
Sends page to process with given page device.
|
void |
setArtBox(Rectangle value)
Sets art box of the page.
|
void |
setBackground(Color value)
Sets the background color of the page.
|
void |
setBackground(Color value)
Sets the background color of the page.
|
void |
setBackgroundImage(Image value)
Gets or sets background image for page (for generator only).
|
void |
setBleedBox(Rectangle value)
Sets bleed box of the page.
|
void |
setCropBox(Rectangle value)
Sets crop box of the page.
|
void |
setDuration(double value)
Sets page display duration.
|
void |
setFooter(HeaderFooter value)
Sets page Footer.
|
void |
setGroup(Group value)
Sets a group attributes class specifying the attributes of the page's page group for use in
the transparent imaging model.
|
void |
setHeader(HeaderFooter value)
Sets page header.
|
void |
setLayers(ArrayList<Layer> value)
Sets layers collection.
|
void |
setLayersInternal(com.aspose.ms.System.Collections.Generic.List<Layer> value)
Sets layers collection.
|
void |
setMediaBox(Rectangle value)
Sets media box of the page.
|
void |
setNoteLineStyle(GraphInfo value)
Sets the line style for notes.
|
void |
setPageInfo(PageInfo value)
Sets the page info.
|
void |
setPageSize(double width,
double height)
Sets page size for page.
|
void |
setParagraphs(Paragraphs value)
Sets the paragraphs.
|
void |
setRect(Rectangle value)
Sets rectangle of the page.
|
void |
setRotate(int value)
Sets rotation of the page.
|
void |
setTabOrder(int value)
Sets tab order of the page.
|
void |
setTocInfo(TocInfo value)
Sets table of contents info.
|
void |
setTransition(com.aspose.pdf.engine.data.IPdfDictionary transition)
Set transition
|
void |
setTrimBox(Rectangle value)
Sets trim box of the page.
|
void |
setWatermark(Watermark value)
Sets the watermark of the page.
|
public final PdfEvent<Page.BeforePageGenerate> OnBeforePageGenerate
public com.aspose.pdf.engine.commondata.IPage EnginePage
public final Image getBackgroundImage()
Gets or sets background image for page (for generator only).
public final void setBackgroundImage(Image value)
Gets or sets background image for page (for generator only).
value
- Image instancepublic TocInfo getTocInfo()
Gets table of contents info.
public void setTocInfo(TocInfo value)
Sets table of contents info.
value
- The table of contents info - default null. If it set this page will contain table of
contents.public HeaderFooter getHeader()
Gets page header.
public void setHeader(HeaderFooter value)
Sets page header.
value
- The page header.public List<Layer> getLayers()
Gets layers collection.
public void setLayers(ArrayList<Layer> value)
Sets layers collection.
value
- : The layers collection.public void setLayersInternal(com.aspose.ms.System.Collections.Generic.List<Layer> value)
Sets layers collection.
value
- : The layers collection.public HeaderFooter getFooter()
Gets page Footer.
public void setFooter(HeaderFooter value)
Sets page Footer.
value
- The page Footer.public Paragraphs getParagraphs()
Gets the paragraphs.
public void setParagraphs(Paragraphs value)
Sets the paragraphs.
value
- Paragraphs valuepublic PageInfo getPageInfo()
Gets the page info.(for generator only)
public void setPageInfo(PageInfo value)
Sets the page info.(for generator only)
value
- The page info.public byte[] convertToPNGMemoryStream()
public IDocument getDocument()
Get document
public Rectangle getRect()
Gets rectangle of the page. Page crop box is returned if specified, otherwise page media box is returned.
Example demonstrates how to get page rectangle: Document document = new Document("sample.pdf"); Page page = document.getPages().get(1); Rectangle pageRect = page.getRect();
public Rectangle getRect_Rename_Namesake()
Gets rectangle of the page. Page crop box is returned if specified, otherwise page media box is returned. Please note that this property don't consider page rotation. To get page rectangle considering rotation please use ActualRect.
Example demonstrates how to get page rectangle: Document document = new Document("sample.pdf"); Page page = document.getPages().get_Item(1); Rectangle pageRect = page.getRect();
public void setRect(Rectangle value)
Sets rectangle of the page. Page crop box is returned if specified, otherwise page media box is returned. Please note that this property don't consider page rotation. To get page rectangle considering rotation please use ActualRect.
value
- Rectangle objectpublic int getColorType()
Gets color type of the pages based on information getting from operators SetColor, images and forms.
ColorType
public GraphInfo getNoteLineStyle()
Gets the line style for notes.(for generator only)
public void setNoteLineStyle(GraphInfo value)
Sets the line style for notes.(for generator only)
value
- : GraphInfo valuepublic boolean isBlank(double fillThresholdFactor)
Gets the flag whether page is blank or not.
fillThresholdFactor
- The fill threshold value that manages the sensitivity of detection. Should be equal or
greater than 0.01.public Rectangle getPageRect(boolean considerRotation)
Returns rectangle of the page.
considerRotation
- If true then rotation of the page will be considered in rect calculation.public Rectangle calculateContentBBox()
Calculates bbox value - rectangle containing contents without visible margins.
public int getTabOrder()
Gets tab order of the page. Possible values: Row, Column. Default, Manual
TabOrder
public void setTabOrder(int value)
Sets tab order of the page. Possible values: Row, Column. Default, Manual
value
- TabOrder objectTabOrder
public double getDuration()
Gets page display duration. This is time in seconds that page shall be displayed during presentation. Returs -1 if duration is not defined.
Document document = new Document("sample.pdf"); Page page = document.getPages().get(1); int pageRect = page.getDuration();
public void setDuration(double value)
Sets page display duration. This is time in seconds that page shall be displayed during presentation.
value
- page display duration.public OperatorCollection getContents()
Gets collection of operators in the content stream of the page. OperatorCollection
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 : (Iterable<Operator>)
contents)
{
System.out.println(op);
}
public Group getGroup()
Gets a group attributes class specifying the attributes of the page's page group for use in the transparent imaging model.
public void setGroup(Group value)
Sets a group attributes class specifying the attributes of the page's page group for use in the transparent imaging model.
value
- Group valuepublic AnnotationCollection getAnnotations()
Gets collection of page annotations. Annotations
public Resources getResources()
Gets page resources. Resources object contains collections of images, forms and fonts.
Resources
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 : (Ierable<XImage>)resources
.getImages())
{
System.out.println(image.getWidth() + ":" + image.getHeight());
}
public int getRotate()
Gets rotation of the page.
Example demonstrates how to determine page rotation. Document document = new Document("sample.pdf"); System.out.println(document.getPages().get(1).getRotate());
Rotation
public void setRotate(int value)
Sets rotation of the page.
value
- Rotation elementRotation
public Rectangle getTrimBox()
Gets trim box of the page.
Example demonstrates how to get trim box of the page: Document document = new Document("sample.pdf"); Rectangle trimBox = document.getPages().get(1).getTrimBox();
public void setTrimBox(Rectangle value)
Sets trim box of the page.
value
- Rectangle valuepublic Rectangle getArtBox()
Gets art box of the page.
Example demonstrates how to get art box of the page: Document document = new Document("sample.pdf"); Rectangle artBox = document.getPages().get(1).getArtBox();
public void setArtBox(Rectangle value)
Sets art box of the page.
value
- Rectangle valuepublic Rectangle getBleedBox()
Gets bleed box of the page.
Example demonstrates how to get bleed box of the page: Document document = new Document("sample.pdf"); Rectangle bleedBox = document.getPages().get(1).getBleedBox();
public void setBleedBox(Rectangle value)
Sets bleed box of the page.
value
- Rectangle valuepublic Rectangle getCropBox()
Gets crop box of the page.
Example demonstrates how to get crop box of the page: Document document = new Document("sample.pdf"); Rectangle cropBox = document.getPages().get_Item(1).getCropBox();
public void setCropBox(Rectangle value)
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));
value
- Rectangle objectpublic Rectangle getMediaBox()
Gets media box of the page.
Example demonstrates how to get media box of the page: Document document = new Document("sample.pdf"); Rectangle mediaBox = document.getPages().get(1).getMediaBox();
public void setMediaBox(Rectangle value)
Sets media box of the page.
value
- Rectanglepublic void sendTo(PageDevice device, OutputStream output)
Sends page to process with given page device.
device
- The device to process page.output
- Result stream which is used with device to save its output.public void accept(AnnotationSelector visitor)
Accepts AnnotationSelector
visitor object that provides functionality to work with
annotations.
visitor
- Annotation selector sobject.public static int rotationToInt(int rotation)
Translates rotation enumeration member into integer value.
rotation
- Rotation enumeratioom member.Rotation
public static int intToRotation(int rotation)
Translates integer value into corresponding rotation enumeration member.
rotation
- Integer value to convertRotation
public void addStamp(Stamp stamp)
Put stamp into page. Stamp can be page number, image or simple text, e.g. some logo.
stamp
- Stamp to add on the page. Each stamp has its coordinates and corresponding properties
regarding to the kind of stamp, i.e. image or text value.public void addImage(InputStream imageStream, Rectangle imageRect)
Adds image onto the page and locates it in the middle of specified rectangle saving image's proportion.
imageStream
- The stream of the image.imageRect
- The position of the image.public void addImage(String hocr, InputStream imageStream, Rectangle imageRect)
Adds searchable image onto the page and locates it in the middle of specified rectangle saving image's proportion.
hocr
- The hocr of the image.imageStream
- The stream of the image.imageRect
- The position of the image.public void addImage(InputStream imageStream, Rectangle imageRect, int imageWidth, int imageHeight, boolean saveImageProportions)
Adds searchable image onto the page and locates it in the middle of specified rectangle saving image's proportion.
imageStream
- InputStream objectimageRect
- Rectangle objectimageWidth
- int valueimageHeight
- int valuesaveImageProportions
- boolean valuepublic void addImage(String imagePath, Rectangle rectangle)
Adds image onto the page and locates it in the middle of specified rectangle saving image's proportion.
imagePath
- The path to image.rectangle
- The position of the image.public void addImage(InputStream stream, Rectangle rectangle, CompositingParameters compositingParameters)
Adds image onto the page and locates it in the middle of specified rectangle saving image's proportion.
stream
- The stream of the image.rectangle
- The position of the image.compositingParameters
- The compositing parameters.public void sendTo(PageDevice device, String outputFileName)
Sends page to process with given page device.
device
- The device to process page.outputFileName
- File which is used with device to save its output.public void flatten()
Removes all static fields located on the page and place their values instead.
public void accept(TextFragmentAbsorber visitor)
Accepts TextFragmentAbsorber
visitor object that provides functionality to work with
text objects.
visitor
- Text absorber object.public void accept(ImagePlacementAbsorber visitor)
Accepts ImagePlacementAbsorber
visitor object that provides functionality to work
with image placement objects.
visitor
- Image placement absorber object.public void accept(TextAbsorber visitor)
Accepts TextAbsorber
visitor object that provides functionality to work with text
objects.
visitor
- Text absorber object.public void setPageSize(double width, double height)
Sets page size for page.
width
- Page width.height
- Page size.public void setTransition(com.aspose.pdf.engine.data.IPdfDictionary transition)
Set transition
transition
- IPdfDictionary objectpublic int getNumber()
Get number of the page.
public Matrix getRotationMatrix()
Gets transfomation matrix for the page.
public ContentsAppender getContentsAppender()
Gets current contents appender. ContentsAppender
public Color getBackground()
Gets the background color of the page.
public void setBackground(Color value)
Sets the background color of the page.
value
- Color objectpublic void setBackground(Color value)
Sets the background color of the page.
value
- Color objectpublic Watermark getWatermark()
Gets the watermark of the page.
public void setWatermark(Watermark value)
Sets the watermark of the page.
value
- Watermark objectpublic void removeObjectReferences(String name)
Remove references to XObject from page contents (i.e. all Do operators which use name of object).
name
- String valuepublic static void removeObjectReferences(OperatorCollection contents, String name)
Remove object references
contents
- OperatorCollection objectname
- valuepublic List<Object> findReferences(String name)
Find references
name
- String valueList<Object>
objectpublic static List<Object> findReferences(OperatorCollection contents, String name)
Returns list of operators which uses resource with specified name.
contents
- OperatorCollection valuename
- String valuepublic void dispose()
Frees up memory
dispose
in interface com.aspose.ms.System.IDisposable
public void fillUsedObjectsTable(com.aspose.ms.System.Collections.Generic.Dictionary<Integer,Integer> usageTable, com.aspose.pdf.engine.data.IPdfDictionary CommonResources)
public void deleteUnusedResources(com.aspose.ms.System.Collections.Generic.Dictionary<Integer,Integer> usageTable)
public void clearContents()
public ArtifactCollection getArtifacts()
Gets collection of artifacts on the page.
public PageActionCollection getActions()
Gets collection of page properties.
public void makeGrayscale()
Converts images on page as grayscaled.
public void freeMemory()
Clears cached data
public String getNotifications()
Returns notifications about inside operations with page content. (Only notifications about paragraph events in text adding scenarios are supported now.)
public byte[] asByteArray(Resolution resolution)
Converts current page as BMP bitmap and than returns array of bytes.
resolution
- The resolution.public String asXml()
Converts current page as xml in utf8 encoding.