java.lang.Object
org.sejda.sambox.pdmodel.PDPage
- All Implemented Interfaces:
PDContentStream,COSObjectable
A page in a PDF document.
- Author:
- Ben Litchfield
-
Constructor Summary
ConstructorsConstructorDescriptionPDPage()Creates a new PDPage instance for embedding, with a size of U.S.PDPage(COSDictionary pageDictionary) Creates a new instance of PDPage for reading.PDPage(PDRectangle mediaBox) Creates a new instance of PDPage for embedding. -
Method Summary
Modifier and TypeMethodDescriptioncropBoxCoordinatesToDraw(Point2D point) Assuming the rotated crop box is plane where the lower left corner has coordinates 0,0 and assuming the given point belongs to this plane, it returns the unrotated media box coordinates where this point should be drawnbooleanGet the page actions.This will return a list of the annotations for this page.getAnnotations(AnnotationFilter annotationFilter) This will return a list of the annotations for this page.A rectangle, expressed in default user space units, defining the extent of the page's meaningful content (including potential white space) as intended by the page's creator The default is the CropBox.getBBox()Returns the bounding box of the contents.A rectangle, expressed in default user space units, defining the region to which the contents of the page should be clipped when output in a production environment.Returns this stream's content, if any.Returns the content streams which make up this page.Convert this standard java object to a COS object.A rectangle, expressed in default user space units, defining the visible region of default user space.Returns the matrix which transforms from the stream's space to user space.A rectangle, expressed in default user space units, defining the boundaries of the physical medium on which the page is intended to be displayed or printed.Get the metadata that is part of the document catalog.A dictionary containing any resources required by the page.intReturns the rotation angle in degrees by which the page should be rotated clockwise when displayed or printed.intThis will get the key of this Page in the structural parent tree.This will get a list of PDThreadBead objects, which are article threads in the document.A rectangle, expressed in default user space units, defining the intended dimensions of the finished page after trimming.floatGet the viewports.booleanReturns true if this page has contents.inthashCode()voidRemoves from the page dictionary all non spec compliant keys.voidsetActions(PDPageAdditionalActions actions) Set the page actions.voidsetAnnotations(List<PDAnnotation> annotations) This will set the list of annotations.voidsetArtBox(PDRectangle artBox) This will set the ArtBox for this page.voidsetBleedBox(PDRectangle bleedBox) This will set the BleedBox for this page.voidsetContents(List<PDStream> contents) This will set the contents of this page.voidsetContents(PDStream contents) This will set the contents of this page.voidsetCropBox(PDRectangle cropBox) This will set the CropBox for this page.voidsetMediaBox(PDRectangle mediaBox) This will set the mediaBox for this page.voidsetMetadata(PDMetadata meta) Set the metadata for this object.voidsetResources(PDResources resources) This will set the resources for this page.voidsetRotation(int rotation) This will set the rotation for this page.voidsetStructParents(int structParents) This will set the key for this page in the structural parent tree.voidsetThreadBeads(List<PDThreadBead> beads) This will set the list of thread beads.voidsetTransition(PDTransition transition) voidsetTransition(PDTransition transition, float duration) Convenient method to set a transition and the display durationvoidsetTrimBox(PDRectangle trimBox) This will set the TrimBox for this page.voidsetUserUnit(float userUnit) Get the user unit.voidsetViewports(List<PDViewportDictionary> viewports) Set the viewports.
-
Constructor Details
-
PDPage
public PDPage()Creates a new PDPage instance for embedding, with a size of U.S. Letter (8.5 x 11 inches). -
PDPage
Creates a new instance of PDPage for embedding.- Parameters:
mediaBox- The MediaBox of the page.
-
PDPage
Creates a new instance of PDPage for reading.- Parameters:
pageDictionary- A page dictionary in a PDF document.
-
-
Method Details
-
getCOSObject
Convert this standard java object to a COS object.- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- The cos object that matches this Java object.
-
getContentStreams
Returns the content streams which make up this page.- Returns:
- content stream iterator
-
getContents
Description copied from interface:PDContentStreamReturns this stream's content, if any.- Specified by:
getContentsin interfacePDContentStream- Returns:
- An InputStream or null.
- Throws:
IOException- If the stream could not be read
-
hasContents
public boolean hasContents()Returns true if this page has contents. -
getResources
A dictionary containing any resources required by the page.- Specified by:
getResourcesin interfacePDContentStream
-
setResources
This will set the resources for this page.- Parameters:
resources- The new resources for this page.
-
getStructParents
public int getStructParents()This will get the key of this Page in the structural parent tree.- Returns:
- the integer key of the page's entry in the structural parent tree or -1 if there isn't any.
-
setStructParents
public void setStructParents(int structParents) This will set the key for this page in the structural parent tree.- Parameters:
structParents- The new key for this page.
-
getBBox
Description copied from interface:PDContentStreamReturns the bounding box of the contents.- Specified by:
getBBoxin interfacePDContentStream
-
getMatrix
Description copied from interface:PDContentStreamReturns the matrix which transforms from the stream's space to user space.- Specified by:
getMatrixin interfacePDContentStream
-
getMediaBox
A rectangle, expressed in default user space units, defining the boundaries of the physical medium on which the page is intended to be displayed or printed. -
getMediaBoxRaw
-
setMediaBox
This will set the mediaBox for this page.- Parameters:
mediaBox- The new mediaBox for this page.
-
getCropBox
A rectangle, expressed in default user space units, defining the visible region of default user space. When the page is displayed or printed, its contents are to be clipped (cropped) to this rectangle. -
getCropBoxRaw
-
setCropBox
This will set the CropBox for this page.- Parameters:
cropBox- The new CropBox for this page.
-
getBleedBox
A rectangle, expressed in default user space units, defining the region to which the contents of the page should be clipped when output in a production environment. The default is the CropBox.- Returns:
- The BleedBox attribute.
-
getBleedBoxRaw
-
setBleedBox
This will set the BleedBox for this page.- Parameters:
bleedBox- The new BleedBox for this page.
-
getTrimBox
A rectangle, expressed in default user space units, defining the intended dimensions of the finished page after trimming. The default is the CropBox.- Returns:
- The TrimBox attribute.
-
getTrimBoxRaw
-
setTrimBox
This will set the TrimBox for this page.- Parameters:
trimBox- The new TrimBox for this page.
-
getArtBox
A rectangle, expressed in default user space units, defining the extent of the page's meaningful content (including potential white space) as intended by the page's creator The default is the CropBox.- Returns:
- The ArtBox attribute.
-
getArtBoxRaw
-
setArtBox
This will set the ArtBox for this page.- Parameters:
artBox- The new ArtBox for this page.
-
getRotation
public int getRotation()Returns the rotation angle in degrees by which the page should be rotated clockwise when displayed or printed. Valid values in a PDF must be a multiple of 90.- Returns:
- The rotation angle in degrees in normalized form (0, 90, 180 or 270) or 0 if invalid or not set at this level.
-
setRotation
public void setRotation(int rotation) This will set the rotation for this page.- Parameters:
rotation- The new rotation for this page in degrees.
-
setContents
This will set the contents of this page.- Parameters:
contents- The new contents of the page.
-
setContents
This will set the contents of this page.- Parameters:
contents- Array of new contents of the page.
-
getThreadBeads
This will get a list of PDThreadBead objects, which are article threads in the document. This will return an empty list of there are no thread beads.- Returns:
- A list of article threads on this page.
-
setThreadBeads
This will set the list of thread beads.- Parameters:
beads- A list of PDThreadBead objects or null.
-
getMetadata
Get the metadata that is part of the document catalog. This will return null if there is no meta data for this object.- Returns:
- The metadata for this object.
-
setMetadata
Set the metadata for this object. This can be null.- Parameters:
meta- The meta data for this object.
-
getActions
Get the page actions.- Returns:
- The Actions for this Page
-
setActions
Set the page actions.- Parameters:
actions- The actions for the page.
-
getTransition
- Returns:
- The page transition associated with this page or null if no transition is defined
-
getAnnotations
This will return a list of the annotations for this page.- Returns:
- List of the PDAnnotation objects, never null. The returned list is backed by the annotations COSArray, so any adding or deleting in this list will change the document too.
-
getAnnotations
This will return a list of the annotations for this page.- Parameters:
annotationFilter- the annotation filter provided allowing to filter out specific annotations- Returns:
- List of the PDAnnotation objects, never null. The returned list is backed by the annotations COSArray, so any adding or deleting in this list will change the document too.
-
cropBoxCoordinatesToDraw
Assuming the rotated crop box is plane where the lower left corner has coordinates 0,0 and assuming the given point belongs to this plane, it returns the unrotated media box coordinates where this point should be drawn- Parameters:
point-- Returns:
-
setAnnotations
This will set the list of annotations. Although this is optional, you should take care that any newly created annotations link back to this page by callingPDAnnotation.setPage(org.sejda.sambox.pdmodel.PDPage). Not doing it can cause trouble when PDFs get signed.- Parameters:
annotations- The new list of annotations.
-
equals
-
hashCode
public int hashCode() -
getResourceCache
- Returns:
- the resource cache associated with this page, or null if there is none.
-
getViewports
Get the viewports.- Returns:
- a list of viewports or null if there is no /VP entry.
-
setViewports
Set the viewports.- Parameters:
viewports- A list of viewports, or null if the entry is to be deleted.
-
getUserUnit
public float getUserUnit()- Returns:
- the user unit. This is a positive number that shall give the size of default user space units, in multiples of 1/72 inch, or 1 if it hasn't been set. This is supported by PDF 1.6 and higher.
-
setUserUnit
public void setUserUnit(float userUnit) Get the user unit. This is a positive number that shall give the size of default user space units, in multiples of 1/72 inch. This is supported by PDF 1.6 and higher.- Parameters:
userUnit- throws IllegalArgumentException if the parameter is not positive.
-
sanitizeDictionary
public void sanitizeDictionary()Removes from the page dictionary all non spec compliant keys. -
getPageTreeParent
-