Class Page
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(int addAfter, Annotation annot) Deprecated.addNewAnnotation(int addAfter, String subType, Rect initialRect) Deprecated.voidaddQRBarcode(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.booleanConvert 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.createAnnotation(String subType, Rect initialRect) Deprecated.voiddelete()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.drawContents(DrawParams drawParams, List<SeparationColorSpace> colorants) Draw the contents of this page in collection of the images.voiddrawContents(BufferedImage image, Matrix matrix, Rect updateRect) Draw the contents of this page to an image, only DeviceRGBA colorModel is supported.voiddrawContents(BufferedImage image, Matrix matrix, Rect updateRect, EnumSet<SmoothFlags> newAntiAlias, boolean doThinLine, boolean bypassCopyPerm) Draw the contents of this page to a BufferedImage, only DeviceRGBA colorModel is supported.booleanFlattens optional content on the page.booleanFlattens optional content on the page.getAnnotation(int annotIndex) Gets the annotIndex annotation on the page.Get the page's ArtBox.getBBox()Get the page's Bounding Box.Get the page's BleedBox.Creates a Content from the Page object's contents and resources.Get the page's CropBox.Export a region of a PDF page to an Image object.getImage(Rect exportRect, PageImageParams ImageParams) Export a region of a PDF page to an Image object.getImage(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spaces) Export a region of a PDF page to an Image object.getImageSeparations(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spacesCollection) Export a region of a PDF page using the specified Separation ColorSpaces to an Image Collection object.getImageSeparations(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spaces, RenderProgressProc progressProc) Get the page's MediaBox.intGets the number of annotations on a page.getOutputPreviewImage(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spaces) Create an Output Preview image used when Soft Proofing a document prior to actual printing.intRetrieve the page number for this PDF page.Retrieve the PDFObject representation of this object.intReports possible page rendering problems.The number of degrees by which the page is rotated clockwise when displayed or printed.Get the page's TrimBox.floatGets the size of default user space units for the page.booleanhasTransparency(boolean includeAnnotAppearances) Checks whether a page uses any transparency features.listInks()Retrieve a list of all inks present on a page.listInks(boolean includeOPI) Retrieve a list of all inks present on a page.makeBufferedImage(Rect exportRect, PageImageParams pip) Export a region of a PDF page to a java.awt.BufferedImage.voidmakeSeparations(SeparationParams params) Generate print color separations for a page.voidremoveAnnotation(int annotIndex) Removes an annotation from the specified page.voidSet the page's ArtBox.voidsetBleedBox(Rect r) Set the page's BleedBox.voidsetCropBox(Rect r) Set the page's CropBox.voidsetMediaBox(Rect r) Set the page's MediaBox.voidsetRotation(PageRotation rotation) The number of degrees by which the page is rotated clockwise when displayed or printed.voidsetTrimBox(Rect r) Set the page's TrimBox.voidsetUserUnit(float userUnit) Sets the size of default user space units for the page.voidSets the page's Content back into the Page, using the same compression filters with which the content was previously encoded.
-
Constructor Details
-
Page
Gets a Page from a document.- Parameters:
doc- The document containing the page to acquire.pageNum- The page number of the page to acquire. The first page is 0.
-
Page
Creates and acquires a new page. The page is inserted into the document at the specified location. Call PDPageRelease() when you are done using the page.- Parameters:
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.
-
-
Method Details
-
delete
public void delete() -
drawContents
Draw the contents of this page to an image, only DeviceRGBA colorModel is supported.- Parameters:
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.
-
drawContents
public void drawContents(BufferedImage image, Matrix matrix, Rect updateRect, EnumSet<SmoothFlags> newAntiAlias, boolean doThinLine, boolean bypassCopyPerm) Draw the contents of this page to a BufferedImage, only DeviceRGBA colorModel is supported.- Parameters:
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.
-
makeBufferedImage
Export a region of a PDF page to a java.awt.BufferedImage. A particular size in pixels can be specified for the exported Bitmap by setting ImageParams.PixelWidth and/or ImageParams.PixelHeight. If the exportRect is smaller than the PDF page and pip.PixelWidth and pip.PixelHeight are set, then the resulting image will be of the size pip.PixelWidth x pip.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 pip.PixelWidth or only pip.PixelHeight. When only one is specified, the function will calculate the other.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. 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 height of the returned image are calculated using the exportRect and a resolution of 300.0. -
drawContents
public List<BufferedImage> drawContents(DrawParams drawParams, List<SeparationColorSpace> colorants) Draw the contents of this page in collection of the images. Each image in collection is a separated channel.- Parameters:
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 ignored- Returns:
- List, that contains buffered image for each ink
-
drawContents
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. Each row of the bitmap is aligned onto a four-byte boundary.The amount of data returned depends on the destRect parameter. Using integer arithmetic:
stride = (width * components + 3) invalid input: '&' ~3
array_size = stride * height
- Parameters:
drawParams- Parameters for the drawing operation- Returns:
- an array of bytes containing the image.
-
setArtBox
Set the page's ArtBox. -
getArtBox
Get the page's ArtBox. -
setBleedBox
Set the page's BleedBox. -
getBleedBox
Get the page's BleedBox. -
setCropBox
Set the page's CropBox. -
getCropBox
Get the page's CropBox. -
setMediaBox
Set the page's MediaBox. -
getMediaBox
Get the page's MediaBox. -
setTrimBox
Set the page's TrimBox. -
getTrimBox
Get the page's TrimBox. -
getBBox
Get the page's Bounding Box. -
getNumAnnotations
public int getNumAnnotations()Gets the number of annotations on a page. Annotations associated with pop-up windows (such as strikeouts) are counted as two annotations. Widget annotations (form fields) are included in the count.- Returns:
- The number of annotations on this page.
-
getAnnotation
Gets the annotIndex annotation on the page.- Parameters:
annotIndex- The index of the annotation to get on a page. The first annotation on a page has an index of zero.- Returns:
- The indexed annotation object.
-
addAnnotation
Deprecated.(Deprecated, function may be removed in the future. Instead, use the constructor for Annotation or a subclass of Annotation.)Adds an annotation at the specified location in a page's annotation array.
- Parameters:
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.
-
addNewAnnotation
Deprecated.(Deprecated, function may be removed in the future. Instead, use the constructor for Annotation or a subclass of Annotation.)Adds an annotation to the page. This method is equivalent to calling PDPageCreateAnnot() followed by PDPageAddAnnot().
- Parameters:
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.- Returns:
- The newly created annotation.
-
createAnnotation
Deprecated.(Deprecated, function may be removed in the future. Instead, use the constructor for Annotation or a subclass of Annotation.)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.
- Parameters:
subType- The subtype of the annotation to add.initialRect- A pointer to a rectangle specifying the annotation's bounds, specified in user space coordinates.- Returns:
- The newly created annotation.
-
removeAnnotation
public void removeAnnotation(int annotIndex) Removes an annotation from the specified page. Annotations are stored in arrays, which are automatically compressed when an annotation is removed. For this reason, if you use a loop in which you remove annotations, structure the code so the loop processes from the highest to the lowest index. If you loop the other direction, you will skip over annotations immediately following ones you remove.- Parameters:
annotIndex- The index (into the page's annotation array) of the annotation to remove.
-
getRotation
The number of degrees by which the page is rotated clockwise when displayed or printed. -
setRotation
The number of degrees by which the page is rotated clockwise when displayed or printed. -
getContent
Creates a Content from the Page object's contents and resources. The Content is cached, so that subsequent calls on the same Page return the same Content.After making changes to the content, make sure to call the UpdateContent method on the Page.
- Returns:
- The content for the page.
-
updateContent
public void updateContent()Sets the page's Content back into the Page, using the same compression filters with which the content was previously encoded.Call this function after making any changes to the Page's content.
-
getImageSeparations
public ImageCollection getImageSeparations(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spacesCollection) Export a region of a PDF page using the specified Separation ColorSpaces to an Image Collection object.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.
- Parameters:
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.
-
getImageSeparations
public ImageCollection getImageSeparations(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spaces, RenderProgressProc progressProc) -
getOutputPreviewImage
public Image getOutputPreviewImage(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spaces) Create an Output Preview image used when Soft Proofing a document prior to actual printing.This method uses renders the specified region of a PDF page using the specified Separation ColorSpaces to an Image.
- Parameters:
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.
-
getImage
Export a region of a PDF page to an Image object.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.
- Parameters:
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.
-
getImage
Export a region of a PDF page to an Image object.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.
- Parameters:
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.
-
getImage
public Image getImage(Rect exportRect, PageImageParams ImageParams, List<SeparationColorSpace> spaces) Export a region of a PDF page to an Image object.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.
- Parameters:
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.
-
getPageNumber
public int getPageNumber()Retrieve the page number for this PDF page.Page numbers always start at zero.
- Returns:
- the number of this page in the Document.
-
getPDFDict
Retrieve the PDFObject representation of this object. -
hasTransparency
public boolean hasTransparency(boolean includeAnnotAppearances) Checks whether a page uses any transparency features.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.
- Parameters:
includeAnnotAppearances- If true, annotation appearances are included in the check; if false, annotation appearances will be ignored.
-
listInks
Retrieve a list of all inks present on a page. -
listInks
Retrieve a list of all inks present on a page.- Parameters:
includeOPI- If true, include inks contained in OPI dictionaries.
-
makeSeparations
Generate print color separations for a page.- Parameters:
params- Parameters for the separation generation, including a list of plates.
-
flattenOptionalContent
public boolean flattenOptionalContent()Flattens optional content on the page.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.
- Returns:
- true if the page was successfully flattened, false otherwise.
-
flattenOptionalContent
Flattens optional content on the page.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.
- Parameters:
occ- The optional content context in which content is checked for visibility.- Returns:
- true if the page was successfully flattened, false otherwise.
-
getRenderWarnings
public int getRenderWarnings()Reports possible page rendering problems.- Returns:
- A bitfield to be compared against PageRenderWarning Enum values.
-
colorConvertContent
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.- Parameters:
params- The color conversion parameters.- Returns:
- True if color conversion occurred. False if nothing was color converted.
-
getUserUnit
public float getUserUnit()Gets the size of default user space units for the page.- Returns:
- the size of default user space units.
-
setUserUnit
public void setUserUnit(float userUnit) Sets the size of default user space units for the page.- Parameters:
userUnit- the size of default user space units.
-
addQRBarcode
Add a QR Two-Dimensional Barcode encoded with the specified Text to the page as an image.- Parameters:
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
-