public class Page
extends java.lang.Object
| Constructor and Description |
|---|
Page(Document doc,
int pageNum)
Gets a Page from a document.
|
Page(Document doc,
int afterPageNum,
Rect mediaBox)
Creates and acquires a new page.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAnnotation(int addAfter,
Annotation annot)
Deprecated.
|
Annotation |
addNewAnnotation(int addAfter,
java.lang.String subType,
Rect initialRect)
Deprecated.
|
void |
addQRBarcode(java.lang.String textToEncode,
double x,
double y,
double width,
double height)
Add a QR Two-Dimensional Barcode encoded with the specified Text to the page as an image.
|
boolean |
colorConvertContent(ColorConvertParams params)
Convert the colors (in place) in a page as specified by the params block by applying an ICC profile to the objects contained in the page.
|
Annotation |
createAnnotation(java.lang.String subType,
Rect initialRect)
Deprecated.
|
void |
delete() |
void |
drawContents(java.awt.image.BufferedImage image,
Matrix matrix,
Rect updateRect)
Draw the contents of this page to an image, only DeviceRGBA colorModel is supported.
|
void |
drawContents(java.awt.image.BufferedImage image,
Matrix matrix,
Rect updateRect,
java.util.EnumSet<SmoothFlags> newAntiAlias,
boolean doThinLine,
boolean bypassCopyPerm)
Draw the contents of this page to a BufferedImage, only DeviceRGBA colorModel is supported.
|
byte[] |
drawContents(DrawParams drawParams)
Draw the contents of the page into a bitmap, and return the raw bitmap data as an array of bytes arranged in left to right, top to bottom order.
|
java.util.List<java.awt.image.BufferedImage> |
drawContents(DrawParams drawParams,
java.util.List<SeparationColorSpace> colorants)
Draw the contents of this page in collection of the images.
|
boolean |
flattenOptionalContent()
Flattens optional content on the page.
|
boolean |
flattenOptionalContent(OptionalContentContext occ)
Flattens optional content on the page.
|
Annotation |
getAnnotation(int annotIndex)
Gets the annotIndex annotation on the page.
|
Rect |
getArtBox()
Get the page's ArtBox.
|
Rect |
getBBox()
Get the page's Bounding Box.
|
Rect |
getBleedBox()
Get the page's BleedBox.
|
Content |
getContent()
Creates a Content from the Page object's contents and resources.
|
Rect |
getCropBox()
Get the page's CropBox.
|
Image |
getImage(Rect exportRect)
Export a region of a PDF page to an Image object.
|
Image |
getImage(Rect exportRect,
PageImageParams ImageParams)
Export a region of a PDF page to an Image object.
|
Image |
getImage(Rect exportRect,
PageImageParams ImageParams,
java.util.List<SeparationColorSpace> spaces)
Export a region of a PDF page to an Image object.
|
ImageCollection |
getImageSeparations(Rect exportRect,
PageImageParams ImageParams,
java.util.List<SeparationColorSpace> spacesCollection)
Export a region of a PDF page using the specified Separation ColorSpaces to an Image Collection object.
|
ImageCollection |
getImageSeparations(Rect exportRect,
PageImageParams ImageParams,
java.util.List<SeparationColorSpace> spaces,
RenderProgressProc progressProc) |
Rect |
getMediaBox()
Get the page's MediaBox.
|
int |
getNumAnnotations()
Gets the number of annotations on a page.
|
Image |
getOutputPreviewImage(Rect exportRect,
PageImageParams ImageParams,
java.util.List<SeparationColorSpace> spaces)
Create an Output Preview image used when Soft Proofing a document prior to actual printing.
|
int |
getPageNumber()
Retrieve the page number for this PDF page.
|
PDFDict |
getPDFDict()
Retrieve the PDFObject representation of this object.
|
int |
getRenderWarnings()
Reports possible page rendering problems.
|
PageRotation |
getRotation()
The number of degrees by which the page is rotated clockwise when displayed or printed.
|
Rect |
getTrimBox()
Get the page's TrimBox.
|
float |
getUserUnit()
Gets the size of default user space units for the page.
|
boolean |
hasTransparency(boolean includeAnnotAppearances)
Checks whether a page uses any transparency features.
|
java.util.List<Ink> |
listInks()
Retrieve a list of all inks present on a page.
|
java.util.List<Ink> |
listInks(boolean includeOPI)
Retrieve a list of all inks present on a page.
|
java.awt.image.BufferedImage |
makeBufferedImage(Rect exportRect,
PageImageParams pip)
Export a region of a PDF page to a java.awt.BufferedImage.
|
void |
makeSeparations(SeparationParams params)
Generate print color separations for a page.
|
void |
removeAnnotation(int annotIndex)
Removes an annotation from the specified page.
|
void |
setArtBox(Rect r)
Set the page's ArtBox.
|
void |
setBleedBox(Rect r)
Set the page's BleedBox.
|
void |
setCropBox(Rect r)
Set the page's CropBox.
|
void |
setMediaBox(Rect r)
Set the page's MediaBox.
|
void |
setRotation(PageRotation rotation)
The number of degrees by which the page is rotated clockwise when displayed or printed.
|
void |
setTrimBox(Rect r)
Set the page's TrimBox.
|
void |
setUserUnit(float userUnit)
Sets the size of default user space units for the page.
|
void |
updateContent()
Sets the page's Content back into the Page, using the same compression filters with which the content was previously encoded.
|
public Page(Document doc, int pageNum)
doc - The document containing the page to acquire.pageNum - The page number of the page to acquire. The first page is 0.public Page(Document doc, int afterPageNum, Rect mediaBox)
doc - The document in which the page is created.afterPageNum - The page number after which the new page is inserted. The first page is 0. Use PDBeforeFirstPage() (see PDExpT.h) to insert the new page at the beginning of a document.mediaBox - A rectangle specifying the page's media box, specified in user space coordinates.public void delete()
public void drawContents(java.awt.image.BufferedImage image,
Matrix matrix,
Rect updateRect)
image - the image into which to rasterize the page.matrix - A matrix to concatenate onto the default page matrix. It is useful for
converting from page to window coordinates and for scaling.updateRect - the rectangle to draw, specified in user coordinates. Any objects
outside the updateRect will not be drawn.public void drawContents(java.awt.image.BufferedImage image,
Matrix matrix,
Rect updateRect,
java.util.EnumSet<SmoothFlags> newAntiAlias,
boolean doThinLine,
boolean bypassCopyPerm)
image - the image into which to rasterize the page.matrix - A matrix to concatenate onto the default page matrix. It is useful for
converting from page to window coordinates and for scaling.updateRect - the rectangle to draw, specified in user coordinates. Any objects
outside the updateRect will not be drawn.newAntiAlias - antialias level.doThinLine - flag to set ThinLineHeuristics, to determine whether thin lines will be fattened non-linearly.bypassCopyPerm - flag to set to determine whether Copy Permissions are bypassed for drawing.public java.awt.image.BufferedImage makeBufferedImage(Rect exportRect, PageImageParams pip)
public java.util.List<java.awt.image.BufferedImage> drawContents(DrawParams drawParams, java.util.List<SeparationColorSpace> colorants)
drawParams - draw parameters for rendering of this pagecolorants - collection of the page's colorants in SeparationColorSpace, that were constructed from an ink and a page. Their tint transforms and alternates will be ignoredpublic byte[] drawContents(DrawParams drawParams)
The amount of data returned depends on the destRect parameter. Using integer arithmetic:
stride = (width * components + 3) & ~3
array_size = stride * height
drawParams - Parameters for the drawing operationpublic void setArtBox(Rect r)
public Rect getArtBox()
public void setBleedBox(Rect r)
public Rect getBleedBox()
public void setCropBox(Rect r)
public Rect getCropBox()
public void setMediaBox(Rect r)
public Rect getMediaBox()
public void setTrimBox(Rect r)
public Rect getTrimBox()
public Rect getBBox()
public int getNumAnnotations()
public Annotation getAnnotation(int annotIndex)
annotIndex - The index of the annotation to get on a page. The first annotation on a page has an index of zero.@Deprecated
public void addAnnotation(int addAfter,
Annotation annot)
Adds an annotation at the specified location in a page's annotation array.
addAfter - The index into the page's annotation array where the annotation is added. The first annotation in the array has an index of zero. Passing a value of -2 adds the annotation to the end of the array. Passing other negative values produces undefined results.annot - The annotation to add.@Deprecated public Annotation addNewAnnotation(int addAfter, java.lang.String subType, Rect initialRect)
Adds an annotation to the page. This method is equivalent to calling PDPageCreateAnnot() followed by PDPageAddAnnot().
addAfter - Where to add the annotation in the page's annotation array. Passing a value of -2 adds the annotation to the end of the array (this is generally what you should do unless you have a need to place the annotation at a special location in the array). Passing a value of -1 adds the annotation to the beginning of the array. Passing other negative values produces undefined results.subType - The subtype of the annotation to add.initialRect - A pointer to a rectangle specifying the annotation's bounds, specified in user space coordinates.@Deprecated public Annotation createAnnotation(java.lang.String subType, Rect initialRect)
Creates a new annotation, associated with the specified page's Document, but not added to the page. Use AddAnnotation to add the annotation to the page.
subType - The subtype of the annotation to add.initialRect - A pointer to a rectangle specifying the annotation's bounds, specified in user space coordinates.public void removeAnnotation(int annotIndex)
annotIndex - The index (into the page's annotation array) of the annotation to remove.public PageRotation getRotation()
public void setRotation(PageRotation rotation)
public Content getContent()
After making changes to the content, make sure to call the UpdateContent method on the Page.
public void updateContent()
Call this function after making any changes to the Page's content.
public ImageCollection getImageSeparations(Rect exportRect, PageImageParams ImageParams, java.util.List<SeparationColorSpace> spacesCollection)
This version of GetImage can be used to specify a particular size in pixels for the exported image by setting ImageParams.PixelWidth and/or ImageParams.PixelHeight.
If the exportRect is smaller than the PDF page and ImageParams.PixelWidth and ImageParams.PixelHeight are set, then the resulting image will be of the size ImageParams.PixelWidth x ImageParams.PixelHeight and contain the area of the page inside the exportRect, scaled to fit.
It is also possible to use this function by specifying only ImageParams.PixelWidth or only ImageParams.PixelHeight. When only one is specified, the function will calculate the other.
exportRect - A Rect describing the region of the page to export, specified in user space coordinates. One user unit corresponds to 1/72 inch. To export the entire page, set this parameter to the page's CropBox. User space coordinates correspond to the unrotated page; the rotation specified in Page.Rotation is not taken into account with these coordinates.ImageParams - A PageImageParams containing additional parameters for the exported image, including the exported image's pixel width, pixel height, and resolution. If these parameters are not specified, the pixel width and pixel height of the image are calculated using the exportRect and a resolution of 300.0.spacesCollection - A collection of SeparationColorSpace class additional parameter for specifying colorants for bitmap rendering. Each SeparationColorSpace must be constructed from an ink and a page. Their tint transforms and alternates will be ignored.public ImageCollection getImageSeparations(Rect exportRect, PageImageParams ImageParams, java.util.List<SeparationColorSpace> spaces, RenderProgressProc progressProc)
public Image getOutputPreviewImage(Rect exportRect, PageImageParams ImageParams, java.util.List<SeparationColorSpace> spaces)
This method uses renders the specified region of a PDF page using the specified Separation ColorSpaces to an Image.
exportRect - A Rect describing the region of the page to export, specified in user space coordinates. One user unit corresponds to 1/72 inch. To export the entire page, set this parameter to the page's CropBox. User space coordinates correspond to the unrotated page; the rotation specified in Page.Rotation is not taken into account with these coordinates.ImageParams - A PageImageParams containing additional parameters for the exported image, including the exported image's pixel width, pixel height, and resolution. If these parameters are not specified, the pixel width and pixel height of the image are calculated using the exportRect and a resolution of 300.0.spaces - A collection of SeparationColorSpace class additional parameter for specifying colorants for bitmap rendering. Each SeparationColorSpace must be constructed from an ink and a page.public Image getImage(Rect exportRect, PageImageParams ImageParams)
This version of GetImage can be used to specify a particular size in pixels for the exported image by setting ImageParams.PixelWidth and/or ImageParams.PixelHeight.
If the exportRect is smaller than the PDF page and ImageParams.PixelWidth and ImageParams.PixelHeight are set, then the resulting image will be of the size ImageParams.PixelWidth x ImageParams.PixelHeight and contain the area of the page inside the exportRect, scaled to fit.
It is also possible to use this function by specifying only ImageParams.PixelWidth or only ImageParams.PixelHeight. When only one is specified, the function will calculate the other.
exportRect - A Rect describing the region of the page to export, specified in user space coordinates. One user unit corresponds to 1/72 inch. To export the entire page, set this parameter to the page's CropBox. User space coordinates correspond to the unrotated page; the rotation specified in Page.Rotation is not taken into account with these coordinates.ImageParams - A PageImageParams containing additional parameters for the exported image, including the exported image's pixel width, pixel height, and resolution. If these parameters are not specified, the pixel width and pixel height of the image are calculated using the exportRect and a resolution of 300.0.public Image getImage(Rect exportRect)
If the exportRect is smaller than the PDF page, then the pixel width and pixel height of the resulting image will be calculated from the exportRect and a resolution of 300.0, containing the area of the page inside the exportRect, scaled to fit. If a specific pixel size or resolution is desired, use the version of GetImage that takes a PageImageParams as a parameter.
exportRect - A Rect describing the region of the page to export, specified in user space coordinates. One user unit corresponds to 1/72 inch. To export the entire page, set this parameter to the page's CropBox. User space coordinates correspond to the unrotated page; the rotation specified in Page.Rotation is not taken into account with these coordinates.public Image getImage(Rect exportRect, PageImageParams ImageParams, java.util.List<SeparationColorSpace> spaces)
This version of GetImage can be used to specify a particular size in pixels for the exported image by setting ImageParams.PixelWidth and/or ImageParams.PixelHeight.
It renders specified page's inks and ignores colorSpace parameter from ImageParams. This function always renders the page in DeviceN colorspace.
If the exportRect is smaller than the PDF page and ImageParams.PixelWidth and ImageParams.PixelHeight are set, then the resulting image will be of the size ImageParams.PixelWidth x ImageParams.PixelHeight and contain the area of the page inside the exportRect, scaled to fit.
It is also possible to use this function by specifying only ImageParams.PixelWidth or only ImageParams.PixelHeight. When only one is specified, the function will calculate the other.
exportRect - A Rect describing the region of the page to export, specified in user space coordinates. One user unit corresponds to 1/72 inch. To export the entire page, set this parameter to the page's CropBox. User space coordinates correspond to the unrotated page; the rotation specified in Page.Rotation is not taken into account with these coordinates.ImageParams - A PageImageParams containing additional parameters for the exported image, including the exported image's pixel width, pixel height, and resolution. If these parameters are not specified, the pixel width and pixel height of the image are calculated using the exportRect and a resolution of 300.0.spaces - A collection of SeparationColorSpace objects. This parameter is used to specify page's inks to be drawn. Each SeparationColorSpace must be constructed from an ink and a page. Their tint transforms and alternates will be ignored.public int getPageNumber()
Page numbers always start at zero.
public PDFDict getPDFDict()
public boolean hasTransparency(boolean includeAnnotAppearances)
Note: To determine whether a page uses transparency, the resources of the page must be enumerated (though the page contents do not need to be parsed). The page resources may not be optimized for slow (browser-based) connections, so calling Page.HasTransparency() before the page has been downloaded may cause unpleasant read behavior and performance problems.
includeAnnotAppearances - If true, annotation appearances are included in the check; if false, annotation appearances will be ignored.public java.util.List<Ink> listInks()
public java.util.List<Ink> listInks(boolean includeOPI)
includeOPI - If true, include inks contained in OPI dictionaries.public void makeSeparations(SeparationParams params)
params - Parameters for the separation generation, including a list of plates.public boolean flattenOptionalContent()
This page will be replaced with a version that has no optional content. The new version of the page will contain only what was visible on the page when the call was made.
The document's default optional content context will be used to determine visibility of optional content.
The optional content information formerly associated with content on the page will NOT be deleted from the document, as it is possible for optional content groups to contain items on multiple pages.
public boolean flattenOptionalContent(OptionalContentContext occ)
This page will be replaced with a version that has no optional content. The new version of the page will contain only what was visible on the page when the call was made.
The optional content information formerly associated with content on the page will NOT be deleted from the document, as it is possible for optional content groups to contain items on multiple pages.
occ - The optional content context in which content is checked for visibility.public int getRenderWarnings()
public boolean colorConvertContent(ColorConvertParams params)
params - The color conversion parameters.public float getUserUnit()
public void setUserUnit(float userUnit)
userUnit - the size of default user space units.public void addQRBarcode(java.lang.String textToEncode,
double x,
double y,
double width,
double height)
textToEncode - The Text to be encoded in the barcodex - The horizontal location on the page in pointsy - The vertical location on the page in pointswidth - The width of the barcode image in pointsheight - The height of the barcode image in points