Class PdfPage
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.PdfPage
-
public class PdfPage extends PdfObjectWrapper<PdfDictionary>
-
-
Field Summary
Fields Modifier and Type Field Description private booleanignorePageRotationForContentAutomatically rotate new content if the page has a rotation ( is disabled by default )private intmcidprivate static java.util.List<PdfName>PAGE_EXCLUDED_KEYSprivate booleanpageRotationInverseMatrixWritten(package private) PdfPagesparentPagesprivate PdfResourcesresourcesprivate static java.util.List<PdfName>XOBJECT_EXCLUDED_KEYS
-
Constructor Summary
Constructors Modifier Constructor Description protectedPdfPage(PdfDictionary pdfObject)protectedPdfPage(PdfDocument pdfDocument)protectedPdfPage(PdfDocument pdfDocument, PageSize pageSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PdfPageaddAnnotation(int index, PdfAnnotation annotation, boolean tagAnnotation)Adds specifiedPdfAnnotationto specified index in annotations array with or without autotagging.PdfPageaddAnnotation(PdfAnnotation annotation)Adds specified annotation to the end of annotations array and tagged it.private booleanaddAnnotationTag(TagTreePointer tagPointer, PdfAnnotation annotation)voidaddAssociatedFile(PdfFileSpec fs)Adds file associated with PDF page and identifies the relationship between them.voidaddAssociatedFile(java.lang.String description, PdfFileSpec fs)Adds file associated with PDF page and identifies the relationship between them.PdfPageaddOutputIntent(PdfOutputIntent outputIntent)AddsPdfOutputIntentthat shall specify the colour characteristics of output devices on which the page might be rendered.private voidcheckIsoConformanceForAnnotation(PdfAnnotation annotation)booleancontainsAnnotation(PdfAnnotation annotation)Checks if page contains the specified annotation.private voidcopyAnnotations(PdfDocument toDocument, PdfPage page, ICopyFilter copyFilter)PdfFormXObjectcopyAsFormXObject(PdfDocument toDocument)Copies page as FormXObject to the specified document.private voidcopyInheritedProperties(PdfPage copyPdfPage, PdfDocument pdfDocument, ICopyFilter copyFilter)PdfPagecopyTo(PdfDocument toDocument)Copies page to the specified document.PdfPagecopyTo(PdfDocument toDocument, IPdfPageExtraCopier copier)Copies page to the specified document.PdfPagecopyTo(PdfDocument toDocument, IPdfPageExtraCopier copier, boolean addPageToDocument, int pageInsertIndex)Copies page and adds it to the specified document to the end or by index if the corresponding parameter is true.private PdfPagecopyTo(PdfPage page, PdfDocument toDocument, IPdfPageExtraCopier copier)voidflush()Flushes page dictionary, its content streams, annotations and thumb image.voidflush(boolean flushResourcesContentStreams)Flushes page dictionary, its content streams, annotations and thumb image.private voidflushAppearanceStreams(PdfDictionary appearanceStreamsDict)private voidflushMustBeIndirectObject(PdfObject obj)private voidflushResourcesContentStreams()private voidflushResourcesContentStreams(PdfDictionary resources)private voidflushWithResources(PdfDictionary objsCollection)java.util.List<PdfAnnotation>getAnnotations()Gets array of annotation dictionaries that shall contain indirect references to all annotations associated with the page.private PdfArraygetAnnots(boolean create)intgetAnnotsSize()Gets the number ofPdfAnnotationassociated with this page.RectanglegetArtBox()Gets theRectangleobject specified by page's ArtBox, that define the extent of the page’s meaningful content (including potential white space) as intended by the page’s creator.PdfArraygetAssociatedFiles(boolean create)Returns files associated with PDF page.RectanglegetBleedBox()Gets theRectangleobject specified by page's BleedBox, that define the region to which the contents of the page shall be clipped when output in a production environment.byte[]getContentBytes()Get decoded bytes for the whole page content.PdfStreamgetContentStream(int index)Gets the content stream at specified 0-based index in the Contents objectPdfArray.intgetContentStreamCount()Gets the size of Contents objectPdfArray.RectanglegetCropBox()Gets theRectanglespecified by page's CropBox, that defines the visible region of default user space.PdfDocumentgetDocument()Gets thePdfDocumentthat owns that page, ornullif such document isn't exist.PdfStreamgetFirstContentStream()private PdfObjectgetInheritedValue(PdfName pdfName, int type)private static PdfObjectgetInheritedValue(PdfPages parentPages, PdfName pdfName)PdfStreamgetLastContentStream()RectanglegetMediaBox()GetsRectangleobject specified by page's Media Box, that defines the boundaries of the physical medium on which the page shall be displayed or printedintgetNextMcid()Calculates and returns the next available for this page's content stream MCID reference.java.util.List<PdfOutline>getOutlines(boolean updateOutlines)This method gets outlines of a current pageRectanglegetPageSize()Gets page size, defined by media box object.RectanglegetPageSizeWithRotation()Gets page size, considering page rotation.java.util.Set<PdfLayer>getPdfLayers()Get all pdf layers stored under this page's annotations/xobjects/resources.PdfResourcesgetResources()Gets thePdfResourceswrapper object for this page resources.(package private) PdfResourcesgetResources(boolean initResourcesField)intgetRotation()Gets the number of degrees by which the page shall be rotated clockwise when displayed or printed.byte[]getStreamBytes(int index)Gets decoded bytes of a certain stream of a page content.intgetStructParentIndex()Gets the key of the page’s entry in the structural parent tree.PdfNamegetTabOrder()Gets a name specifying the tab order that shall be used for annotations on the page.PdfImageXObjectgetThumbnailImage()Sets a stream object that shall define the page’s thumbnail image.RectanglegetTrimBox()Gets theRectangleobject specified by page's TrimBox object, that define the intended dimensions of the finished page after trimming.PdfStreamgetXmpMetadata()Gets the XMP Metadata object.(package private) PdfDictionaryinitResources(boolean initResourcesField)private static booleanisAnnotInvisible(PdfAnnotation annotation)booleanisIgnorePageRotationForContent()(package private) booleanisPageRotationInverseMatrixWritten()Checks if page rotation inverse matrix (which rotates content into the opposite direction from page rotation direction in order to give the impression of the not rotated text) is already applied to the page content stream.private booleanisPdfUA2Document()protected booleanisWrappedObjectMustBeIndirect()Defines if the object behind this wrapper must be an indirect object in the resultant document.private PdfStreamnewContentStream(boolean before)PdfStreamnewContentStreamAfter()PdfStreamnewContentStreamBefore()PdfPageput(PdfName key, PdfObject value)Helper method that associates specified value with the specified key in the underlyingPdfDictionary.private voidrebuildFormFieldParent(PdfDictionary field, PdfDictionary newField, PdfDocument toDocument)private voidrebuildFormFieldParent(PdfDictionary field, PdfDictionary newField, PdfDocument toDocument, java.util.Set<PdfDictionary> visitedForms)(package private) voidreleaseInstanceFields()PdfPageremove(PdfName key)Helper method that removes the value associated with the specified key from the underlyingPdfDictionary.PdfPageremoveAnnotation(PdfAnnotation annotation)Removes an annotation from the page.PdfPageremoveAnnotation(PdfAnnotation annotation, boolean rememberTagPointer)Removes an annotation from the page.PdfPagesetAdditionalAction(PdfName key, PdfAction action)Helper method to add an additional action to this page.PdfPagesetArtBox(Rectangle rectangle)Sets the ArtBox object, that define the extent of the page’s meaningful content (including potential white space) as intended by the page’s creator.PdfPagesetBleedBox(Rectangle rectangle)Sets the BleedBox object, that defines the region to which the contents of the page shall be clipped when output in a production environment.PdfPagesetCropBox(Rectangle rectangle)Sets the CropBox object, that defines the visible region of default user space.PdfPagesetIgnorePageRotationForContent(boolean ignorePageRotationForContent)If true - defines that in case the page has a rotation, then new content will be automatically rotated in the opposite direction.PdfPagesetMediaBox(Rectangle rectangle)Sets the Media Box object, that defines the boundaries of the physical medium on which the page shall be displayed or printed.PdfPagesetPageLabel(PageLabelNumberingStyle numberingStyle, java.lang.String labelPrefix)This method adds or replaces a page label.PdfPagesetPageLabel(PageLabelNumberingStyle numberingStyle, java.lang.String labelPrefix, int firstPage)This method adds or replaces a page label.(package private) voidsetPageRotationInverseMatrixWritten()Specifies that page rotation inverse matrix (which rotates content into the opposite direction from page rotation direction in order to give the impression of the not rotated text) is applied to the page content stream.PdfPagesetResources(PdfResources pdfResources)SetsPdfResourcesobject.PdfPagesetRotation(int degAngle)Sets the page rotation.PdfPagesetTabOrder(PdfName tabOrder)Sets a name specifying the tab order that shall be used for annotations on the page.PdfPagesetThumbnailImage(PdfImageXObject thumb)Sets a stream object that shall define the page’s thumbnail image.PdfPagesetTrimBox(Rectangle rectangle)Sets the TrimBox object, that define the intended dimensions of the finished page after trimming.PdfPagesetXmpMetadata(byte[] xmpMetadata)Sets the XMP Metadata.PdfPagesetXmpMetadata(XMPMeta xmpMeta)Serializes XMP Metadata to byte array and sets it.PdfPagesetXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions)Serializes XMP Metadata to byte array and sets it.private voidtagAnnotation(PdfAnnotation annotation)(package private) voidtryFlushPageTags()-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
-
-
-
Field Detail
-
resources
private PdfResources resources
-
mcid
private int mcid
-
parentPages
PdfPages parentPages
-
PAGE_EXCLUDED_KEYS
private static final java.util.List<PdfName> PAGE_EXCLUDED_KEYS
-
XOBJECT_EXCLUDED_KEYS
private static final java.util.List<PdfName> XOBJECT_EXCLUDED_KEYS
-
ignorePageRotationForContent
private boolean ignorePageRotationForContent
Automatically rotate new content if the page has a rotation ( is disabled by default )
-
pageRotationInverseMatrixWritten
private boolean pageRotationInverseMatrixWritten
-
-
Constructor Detail
-
PdfPage
protected PdfPage(PdfDictionary pdfObject)
-
PdfPage
protected PdfPage(PdfDocument pdfDocument, PageSize pageSize)
-
PdfPage
protected PdfPage(PdfDocument pdfDocument)
-
-
Method Detail
-
getPageSize
public Rectangle getPageSize()
Gets page size, defined by media box object. This method doesn't take page rotation into account.- Returns:
Rectanglethat specify page size.
-
getPageSizeWithRotation
public Rectangle getPageSizeWithRotation()
Gets page size, considering page rotation.- Returns:
Rectanglethat specify size of rotated page.
-
getRotation
public int getRotation()
Gets the number of degrees by which the page shall be rotated clockwise when displayed or printed. Shall be a multiple of 90.- Returns:
intnumber of degrees. Default value: 0
-
setRotation
public PdfPage setRotation(int degAngle)
Sets the page rotation.- Parameters:
degAngle- theintnumber of degrees by which the page shall be rotated clockwise when displayed or printed. Shall be a multiple of 90.- Returns:
- this
PdfPageinstance.
-
getContentStream
public PdfStream getContentStream(int index)
Gets the content stream at specified 0-based index in the Contents objectPdfArray. The situation when Contents object is aPdfStreamis treated like a one element array.- Parameters:
index- theintindex of returnedPdfStream.- Returns:
PdfStreamobject at specified index; will return null in case page dictionary doesn't adhere to the specification, meaning that the document is an invalid PDF.- Throws:
java.lang.IndexOutOfBoundsException- if the index is out of range
-
getContentStreamCount
public int getContentStreamCount()
Gets the size of Contents objectPdfArray. The situation when Contents object is aPdfStreamis treated like a one element array.- Returns:
- the
intsize of Contents object, or 1 if Contents object is aPdfStream.
-
getFirstContentStream
public PdfStream getFirstContentStream()
- Returns:
- first
PdfStreamin Contents object, ornullif Contents is empty.
-
getLastContentStream
public PdfStream getLastContentStream()
- Returns:
- first
PdfStreamin Contents object, ornullif Contents is empty.
-
newContentStreamBefore
public PdfStream newContentStreamBefore()
Creates newPdfStreamobject and puts it at the beginning of Contents array (if Contents object isPdfStreamit will be replaced with one-element array).- Returns:
- Created
PdfStreamobject.
-
newContentStreamAfter
public PdfStream newContentStreamAfter()
Creates newPdfStreamobject and puts it at the end ofContentsarray (if Contents object isPdfStreamit will be replaced with one-element array).- Returns:
- Created
PdfStreamobject.
-
getResources
public PdfResources getResources()
Gets thePdfResourceswrapper object for this page resources. If page doesn't have resource object, then it will be inherited from page's parents. If neither parents nor page has the resource object, then the new one is created and added to page dictionary.
NOTE: If you'll try to modify the inherited resources, then the new resources object will be created, so you won't change the parent's resources. This new object under the wrapper will be added to page dictionary onflush(), or you can add it manually with this line, if needed:
getPdfObject().put(PdfName.Resources, getResources().getPdfObject());- Returns:
PdfResourceswrapper of the page.
-
getResources
PdfResources getResources(boolean initResourcesField)
-
initResources
PdfDictionary initResources(boolean initResourcesField)
-
setResources
public PdfPage setResources(PdfResources pdfResources)
SetsPdfResourcesobject.- Parameters:
pdfResources-PdfResourcesto set.- Returns:
- this
PdfPageinstance.
-
setXmpMetadata
public PdfPage setXmpMetadata(byte[] xmpMetadata) throws java.io.IOException
Sets the XMP Metadata.- Parameters:
xmpMetadata- thebyte[]of XMP Metadata to set.- Returns:
- this
PdfPageinstance. - Throws:
java.io.IOException- in case of writing error.
-
setXmpMetadata
public PdfPage setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions) throws XMPException, java.io.IOException
Serializes XMP Metadata to byte array and sets it.- Parameters:
xmpMeta- theXMPMetaobject to set.serializeOptions- theSerializeOptionsused while serialization.- Returns:
- this
PdfPageinstance. - Throws:
XMPException- in case of XMP Metadata serialization error.java.io.IOException- in case of writing error.
-
setXmpMetadata
public PdfPage setXmpMetadata(XMPMeta xmpMeta) throws XMPException, java.io.IOException
Serializes XMP Metadata to byte array and sets it. Uses padding equals to 2000.- Parameters:
xmpMeta- theXMPMetaobject to set.- Returns:
- this
PdfPageinstance. - Throws:
XMPException- in case of XMP Metadata serialization error.java.io.IOException- in case of writing error.
-
getXmpMetadata
public PdfStream getXmpMetadata()
Gets the XMP Metadata object.- Returns:
PdfStreamobject, that represent XMP Metadata.
-
copyTo
public PdfPage copyTo(PdfDocument toDocument)
Copies page to the specified document.
NOTE: Works only for pages from the document opened in reading mode, otherwise an exception is thrown.- Parameters:
toDocument- a document to copy page to.- Returns:
- copied
PdfPage.
-
copyTo
public PdfPage copyTo(PdfDocument toDocument, IPdfPageExtraCopier copier)
Copies page to the specified document.
NOTE: Works only for pages from the document opened in reading mode, otherwise an exception is thrown.- Parameters:
toDocument- a document to copy page to.copier- a copier which bears a special copy logic. May be null. It is recommended to use the same instance ofIPdfPageExtraCopierfor the same output document.- Returns:
- copied
PdfPage.
-
copyTo
public PdfPage copyTo(PdfDocument toDocument, IPdfPageExtraCopier copier, boolean addPageToDocument, int pageInsertIndex)
Copies page and adds it to the specified document to the end or by index if the corresponding parameter is true.
NOTE: Works only for pages from the document opened in reading mode, otherwise an exception is thrown. NOTE: If both documents (from which and to which the copy is made) are tagged, you must additionally call theIPdfPageFormCopier.recreateAcroformToProcessCopiedFields(PdfDocument)method after copying the tag structure to process copied fields, like add them to the document and merge fields with the same names.- Parameters:
toDocument- a document to copy page to.copier- a copier which bears a special copy logic. May be null. It is recommended to use the same instance ofIPdfPageExtraCopierfor the same output document.addPageToDocument- true if page should be added to document.pageInsertIndex- position to add the page to, if -1 page will be added to the end of the document, will be ignored if addPageToDocument is false.- Returns:
- copied
PdfPage.
-
getPdfLayers
public java.util.Set<PdfLayer> getPdfLayers()
Get all pdf layers stored under this page's annotations/xobjects/resources. Note that it will include all layers, even those already stored under /OCProperties entry in catalog. To get only unique layers, you can simply exclude ocgs, which already present in catalog.- Returns:
- set of pdf layers, associated with this page.
-
copyAsFormXObject
public PdfFormXObject copyAsFormXObject(PdfDocument toDocument) throws java.io.IOException
Copies page as FormXObject to the specified document.- Parameters:
toDocument- a document to copy to.- Returns:
- copied
PdfFormXObjectobject. - Throws:
java.io.IOException- if an I/O error occurs.
-
getDocument
public PdfDocument getDocument()
Gets thePdfDocumentthat owns that page, ornullif such document isn't exist.- Returns:
PdfDocumentthat owns that page, ornullif such document isn't exist.
-
flush
public void flush()
Flushes page dictionary, its content streams, annotations and thumb image.If the page belongs to the document which is tagged, page flushing also triggers flushing of the tags, which are considered to belong to the page. The logic that defines if the given tag (structure element) belongs to the page is the following: if all the marked content references (dictionary or number references), that are the descendants of the given structure element, belong to the current page - the tag is considered to belong to the page. If tag has descendants from several pages - it is flushed, if all other pages except the current one are flushed.
- Overrides:
flushin classPdfObjectWrapper<PdfDictionary>
-
flush
public void flush(boolean flushResourcesContentStreams)
Flushes page dictionary, its content streams, annotations and thumb image. IfflushResourcesContentStreamsis true, all content streams that are rendered on this page (like FormXObjects, annotation appearance streams, patterns) and also all images associated with this page will also be flushed.For notes about tag structure flushing see
PdfPage#flush() method.If
PdfADocumentis used, flushing will be applied only ifflushResourcesContentStreamsis true.Be careful with handling document in which some of the pages are flushed. Keep in mind that flushed objects are finalized and are completely written to the output stream. This frees their memory but makes it impossible to modify or read data from them. Whenever there is an attempt to modify or to fetch flushed object inner contents an exception will be thrown. Flushing is only possible for objects in the writing and stamping modes, also its possible to flush modified objects in append mode.
- Parameters:
flushResourcesContentStreams- if true all content streams that are rendered on this page (like form xObjects, annotation appearance streams, patterns) and also all images associated with this page will be flushed.
-
getMediaBox
public Rectangle getMediaBox()
GetsRectangleobject specified by page's Media Box, that defines the boundaries of the physical medium on which the page shall be displayed or printed- Returns:
Rectangleobject specified by page Media Box, expressed in default user space units.- Throws:
PdfException- in case of any error while reading MediaBox object.
-
setMediaBox
public PdfPage setMediaBox(Rectangle rectangle)
Sets the Media Box object, that defines the boundaries of the physical medium on which the page shall be displayed or printed.
-
getCropBox
public Rectangle getCropBox()
Gets theRectanglespecified by page's CropBox, that defines the visible region of default user space. When the page is displayed or printed, its contents shall be clipped (cropped) to this rectangle and then shall be imposed on the output medium in some implementation-defined manner.- Returns:
- the
Rectangleobject specified by pages's CropBox, expressed in default user space units. MediaBox by default.
-
setCropBox
public PdfPage setCropBox(Rectangle rectangle)
Sets the CropBox object, that defines the visible region of default user space. When the page is displayed or printed, its contents shall be clipped (cropped) to this rectangle and then shall be imposed on the output medium in some implementation-defined manner.
-
setBleedBox
public PdfPage setBleedBox(Rectangle rectangle)
Sets the BleedBox object, that defines the region to which the contents of the page shall be clipped when output in a production environment.
-
getBleedBox
public Rectangle getBleedBox()
Gets theRectangleobject specified by page's BleedBox, that define the region to which the contents of the page shall be clipped when output in a production environment.- Returns:
- the
Rectangleobject specified by page's BleedBox, expressed in default user space units. CropBox by default.
-
setArtBox
public PdfPage setArtBox(Rectangle rectangle)
Sets the ArtBox object, that define the extent of the page’s meaningful content (including potential white space) as intended by the page’s creator.
-
getArtBox
public Rectangle getArtBox()
Gets theRectangleobject specified by page's ArtBox, that define the extent of the page’s meaningful content (including potential white space) as intended by the page’s creator.- Returns:
- the
Rectangleobject specified by page's ArtBox, expressed in default user space units. CropBox by default.
-
setTrimBox
public PdfPage setTrimBox(Rectangle rectangle)
Sets the TrimBox object, that define the intended dimensions of the finished page after trimming.
-
getTrimBox
public Rectangle getTrimBox()
Gets theRectangleobject specified by page's TrimBox object, that define the intended dimensions of the finished page after trimming.- Returns:
- the
Rectangleobject specified by page's TrimBox, expressed in default user space units. CropBox by default.
-
getContentBytes
public byte[] getContentBytes()
Get decoded bytes for the whole page content.- Returns:
- byte array.
- Throws:
PdfException- in case of anyIOException.
-
getStreamBytes
public byte[] getStreamBytes(int index)
Gets decoded bytes of a certain stream of a page content.- Parameters:
index- index of stream inside Content.- Returns:
- byte array.
- Throws:
PdfException- in case of anyIOException.
-
getNextMcid
public int getNextMcid()
Calculates and returns the next available for this page's content stream MCID reference.- Returns:
- calculated MCID reference.
- Throws:
PdfException- in case of not tagged document.
-
getStructParentIndex
public int getStructParentIndex()
Gets the key of the page’s entry in the structural parent tree.- Returns:
- the key of the page’s entry in the structural parent tree. If page has no entry in the structural parent tree, returned value is -1.
-
setAdditionalAction
public PdfPage setAdditionalAction(PdfName key, PdfAction action)
Helper method to add an additional action to this page. May be used in chain.
-
getAnnotations
public java.util.List<PdfAnnotation> getAnnotations()
Gets array of annotation dictionaries that shall contain indirect references to all annotations associated with the page.- Returns:
- the
List<PdfAnnotation> containing all page's annotations.
-
containsAnnotation
public boolean containsAnnotation(PdfAnnotation annotation)
Checks if page contains the specified annotation.- Parameters:
annotation- thePdfAnnotationto check.- Returns:
trueif page contains specified annotation andfalseotherwise.
-
addAnnotation
public PdfPage addAnnotation(PdfAnnotation annotation)
Adds specified annotation to the end of annotations array and tagged it. May be used in chain.- Parameters:
annotation- thePdfAnnotationto add.- Returns:
- this
PdfPageinstance.
-
addAnnotation
public PdfPage addAnnotation(int index, PdfAnnotation annotation, boolean tagAnnotation)
Adds specifiedPdfAnnotationto specified index in annotations array with or without autotagging. May be used in chain.- Parameters:
index- the index at which specified annotation will be added. If-1then annotation will be added to the end of array.annotation- thePdfAnnotationto add.tagAnnotation- iftruethe added annotation will be autotagged.- Returns:
- this
PdfPageinstance.
-
removeAnnotation
public PdfPage removeAnnotation(PdfAnnotation annotation)
Removes an annotation from the page.When document is tagged a corresponding logical structure content item for this annotation will be removed; its immediate structure element parent will be removed as well if the following conditions are met: annotation content item was its single child and structure element role is either Annot or Form.
- Parameters:
annotation- an annotation to be removed- Returns:
- this
PdfPageinstance.
-
removeAnnotation
public PdfPage removeAnnotation(PdfAnnotation annotation, boolean rememberTagPointer)
Removes an annotation from the page.When document is tagged a corresponding logical structure content item for this annotation will be removed; its immediate structure element parent will be removed as well if the following conditions are met: annotation content item was its single child and structure element role is either Annot or Form.
- Parameters:
annotation- an annotation to be removedrememberTagPointer- if set to true, theTagStructureContext.getAutoTaggingPointer()instance ofTagTreePointerwill be moved to the parent of the removed annotation tag. Can be used to add a new annotation to the same place in the tag structure. (E.g. when merged Acroform field is split into a field and a pure widget, the page annotation needs to be replaced by the new one)- Returns:
- this
PdfPageinstance.
-
getAnnotsSize
public int getAnnotsSize()
Gets the number ofPdfAnnotationassociated with this page.- Returns:
- the
intnumber ofPdfAnnotationassociated with this page.
-
getOutlines
public java.util.List<PdfOutline> getOutlines(boolean updateOutlines)
This method gets outlines of a current page- Parameters:
updateOutlines- if the flag istrue, the method reads the whole document and creates outline tree. If the flag isfalse, the method gets cached outline tree (if it was cached via calling getOutlines method before).- Returns:
- return all outlines of a current page
-
isIgnorePageRotationForContent
public boolean isIgnorePageRotationForContent()
- Returns:
- true - if in case the page has a rotation, then new content will be automatically rotated in the opposite direction. On the rotated page this would look like if new content ignores page rotation.
-
setIgnorePageRotationForContent
public PdfPage setIgnorePageRotationForContent(boolean ignorePageRotationForContent)
If true - defines that in case the page has a rotation, then new content will be automatically rotated in the opposite direction. On the rotated page this would look like if new content ignores page rotation. Default value -false.- Parameters:
ignorePageRotationForContent- - true to ignore rotation of the new content on the rotated page.- Returns:
- this
PdfPageinstance.
-
setPageLabel
public PdfPage setPageLabel(PageLabelNumberingStyle numberingStyle, java.lang.String labelPrefix)
This method adds or replaces a page label.- Parameters:
numberingStyle- The numbering style that shall be used for the numeric portion of each page label. May be NULLlabelPrefix- The label prefix for page labels in this range. May be NULL- Returns:
- this
PdfPageinstance.
-
setPageLabel
public PdfPage setPageLabel(PageLabelNumberingStyle numberingStyle, java.lang.String labelPrefix, int firstPage)
This method adds or replaces a page label.- Parameters:
numberingStyle- The numbering style that shall be used for the numeric portion of each page label. May be NULLlabelPrefix- The label prefix for page labels in this range. May be NULLfirstPage- The value of the numeric portion for the first page label in the range. Must be greater or equal 1.- Returns:
- this
PdfPageinstance.
-
setTabOrder
public PdfPage setTabOrder(PdfName tabOrder)
Sets a name specifying the tab order that shall be used for annotations on the page. The possible values arePdfName.R(row order),PdfName.C(column order), andPdfName.S(structure order). Beginning with PDF 2.0, the possible values also includePdfName.A(annotations array order) andPdfName.W(widget order). See ISO 32000 12.5, "Annotations" for details.
-
getTabOrder
public PdfName getTabOrder()
Gets a name specifying the tab order that shall be used for annotations on the page. The possible values arePdfName.R(row order),PdfName.C(column order), andPdfName.S(structure order). Beginning with PDF 2.0, the possible values also includePdfName.A(annotations array order) andPdfName.W(widget order). See ISO 32000 12.5, "Annotations" for details.- Returns:
- a
PdfNamespecifying the annotations tab order or null if tab order is not defined.
-
setThumbnailImage
public PdfPage setThumbnailImage(PdfImageXObject thumb)
Sets a stream object that shall define the page’s thumbnail image. Thumbnail images represent the contents of its pages in miniature form- Parameters:
thumb- the thumbnail image- Returns:
- this
PdfPageobject
-
getThumbnailImage
public PdfImageXObject getThumbnailImage()
Sets a stream object that shall define the page’s thumbnail image. Thumbnail images represent the contents of its pages in miniature form- Returns:
- the thumbnail image, or
nullif it is not present
-
addOutputIntent
public PdfPage addOutputIntent(PdfOutputIntent outputIntent)
AddsPdfOutputIntentthat shall specify the colour characteristics of output devices on which the page might be rendered.- Parameters:
outputIntent-PdfOutputIntentto add.- Returns:
- this
PdfPageobject - See Also:
PdfOutputIntent
-
put
public PdfPage put(PdfName key, PdfObject value)
Helper method that associates specified value with the specified key in the underlyingPdfDictionary. Can be used in method chaining.
-
remove
public PdfPage remove(PdfName key)
Helper method that removes the value associated with the specified key from the underlyingPdfDictionary. Can be used in method chaining.
-
addAssociatedFile
public void addAssociatedFile(java.lang.String description, PdfFileSpec fs)Adds file associated with PDF page and identifies the relationship between them.Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the page dictionary. If description is provided, it also will add file description to catalog Names tree.
For associated files their associated file specification dictionaries shall include the AFRelationship key
- Parameters:
description- the file descriptionfs- file specification dictionary of associated file
-
addAssociatedFile
public void addAssociatedFile(PdfFileSpec fs)
Adds file associated with PDF page and identifies the relationship between them.
Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the page dictionary.
For associated files their associated file specification dictionaries shall include the AFRelationship key
- Parameters:
fs- file specification dictionary of associated file
-
getAssociatedFiles
public PdfArray getAssociatedFiles(boolean create)
Returns files associated with PDF page.- Parameters:
create- defines whether AF arrays will be created if it doesn't exist- Returns:
- associated files array
-
tryFlushPageTags
void tryFlushPageTags()
-
releaseInstanceFields
void releaseInstanceFields()
-
isPageRotationInverseMatrixWritten
boolean isPageRotationInverseMatrixWritten()
Checks if page rotation inverse matrix (which rotates content into the opposite direction from page rotation direction in order to give the impression of the not rotated text) is already applied to the page content stream. SeesetIgnorePageRotationForContent(boolean)andPageContentRotationHelper.- Returns:
trueif inverse matrix is already applied,falseotherwise
-
setPageRotationInverseMatrixWritten
void setPageRotationInverseMatrixWritten()
Specifies that page rotation inverse matrix (which rotates content into the opposite direction from page rotation direction in order to give the impression of the not rotated text) is applied to the page content stream. SeesetIgnorePageRotationForContent(boolean)andPageContentRotationHelper.
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Description copied from class:PdfObjectWrapperDefines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary>- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
isAnnotInvisible
private static boolean isAnnotInvisible(PdfAnnotation annotation)
-
tagAnnotation
private void tagAnnotation(PdfAnnotation annotation)
-
isPdfUA2Document
private boolean isPdfUA2Document()
-
checkIsoConformanceForAnnotation
private void checkIsoConformanceForAnnotation(PdfAnnotation annotation)
-
addAnnotationTag
private boolean addAnnotationTag(TagTreePointer tagPointer, PdfAnnotation annotation)
-
copyTo
private PdfPage copyTo(PdfPage page, PdfDocument toDocument, IPdfPageExtraCopier copier)
-
getAnnots
private PdfArray getAnnots(boolean create)
-
getInheritedValue
private static PdfObject getInheritedValue(PdfPages parentPages, PdfName pdfName)
-
newContentStream
private PdfStream newContentStream(boolean before)
-
copyAnnotations
private void copyAnnotations(PdfDocument toDocument, PdfPage page, ICopyFilter copyFilter)
-
flushResourcesContentStreams
private void flushResourcesContentStreams()
-
flushResourcesContentStreams
private void flushResourcesContentStreams(PdfDictionary resources)
-
flushWithResources
private void flushWithResources(PdfDictionary objsCollection)
-
flushAppearanceStreams
private void flushAppearanceStreams(PdfDictionary appearanceStreamsDict)
-
flushMustBeIndirectObject
private void flushMustBeIndirectObject(PdfObject obj)
-
copyInheritedProperties
private void copyInheritedProperties(PdfPage copyPdfPage, PdfDocument pdfDocument, ICopyFilter copyFilter)
-
rebuildFormFieldParent
private void rebuildFormFieldParent(PdfDictionary field, PdfDictionary newField, PdfDocument toDocument)
-
rebuildFormFieldParent
private void rebuildFormFieldParent(PdfDictionary field, PdfDictionary newField, PdfDocument toDocument, java.util.Set<PdfDictionary> visitedForms)
-
-