public class PdfPage extends PdfObjectWrapper<PdfDictionary>
Modifier | Constructor and Description |
---|---|
protected |
PdfPage(PdfDictionary pdfObject) |
protected |
PdfPage(PdfDocument pdfDocument) |
protected |
PdfPage(PdfDocument pdfDocument, PageSize pageSize) |
Modifier and Type | Method and Description |
---|---|
PdfPage |
addAnnotation(int index, PdfAnnotation annotation, boolean tagAnnotation)
Adds specified PdfAnnotation to specified index in annotations array with or without autotagging.
|
PdfPage |
addAnnotation(PdfAnnotation annotation)
Adds specified annotation to the end of annotations array and tagged it.
|
boolean |
containsAnnotation(PdfAnnotation annotation)
Checks if page contains the specified annotation.
|
PdfFormXObject |
copyAsFormXObject(PdfDocument toDocument)
Copies page as FormXObject to the specified document.
|
PdfPage |
copyTo(PdfDocument toDocument)
Copies page to the specified document.
|
PdfPage |
copyTo(PdfDocument toDocument, IPdfPageExtraCopier copier)
Copies page to the specified document.
|
void |
flush()
Flushes page and it's content stream.
|
void |
flush(boolean flushContentStreams)
Flushes page and its content stream.
|
List<PdfAnnotation> |
getAnnotations()
Gets array of annotation dictionaries that shall contain indirect references to all annotations associated with the page.
|
int |
getAnnotsSize()
Gets the number of PdfAnnotation associated with this page.
|
Rectangle |
getArtBox()
Gets the Rectangle object 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.
|
byte[] |
getContentBytes()
Get decoded bytes for the whole page content.
|
PdfStream |
getContentStream(int index)
Gets the content stream at specified 0-based index in the Contents object PdfArray .
|
int |
getContentStreamCount()
Gets the size of Contents object PdfArray .
|
Rectangle |
getCropBox()
Gets the Rectangle specified by page's CropBox, that defines the visible region of default user space.
|
PdfDocument |
getDocument()
Gets the PdfDocument that owns that page, or null if such document isn't exist.
|
PdfStream |
getFirstContentStream()
|
PdfStream |
getLastContentStream()
|
Rectangle |
getMediaBox()
Gets Rectangle object specified by page's Media Box, that defines the boundaries of the physical medium on which the page shall be displayed or printed
|
int |
getNextMcid()
Calculates and returns next available MCID reference.
|
List<PdfOutline> |
getOutlines(boolean updateOutlines)
This method gets outlines of a current page
|
Rectangle |
getPageSize()
Gets page size, defined by media box object.
|
Rectangle |
getPageSizeWithRotation()
Gets page size, considering page rotation.
|
PdfResources |
getResources()
Gets the PdfResources wrapper object for this page resources.
|
int |
getRotation()
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.
|
Integer |
getStructParentIndex()
Gets Integer key of the page’s entry in the structural parent tree.
|
Rectangle |
getTrimBox()
Gets the Rectangle object specified by page's TrimBox object, that define the intended dimensions of the finished page after trimming.
|
PdfStream |
getXmpMetadata()
Gets the XMP Metadata object.
|
boolean |
isIgnorePageRotationForContent() |
boolean |
isPageRotationInverseMatrixWritten()
This flag is meaningful for the case, when page rotation is applied and ignorePageRotationForContent is set to true.
|
protected boolean |
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.
|
PdfStream |
newContentStreamAfter()
|
PdfStream |
newContentStreamBefore()
|
PdfPage |
put(PdfName key, PdfObject value)
Helper method that associate specified value with specified key in the underlined PdfDictionary .
|
PdfPage |
removeAnnotation(PdfAnnotation annotation)
Removes an annotation from the page.
|
PdfPage |
setAdditionalAction(PdfName key, PdfAction action)
Helper method to add an additional action to this page.
|
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.
|
PdfPage |
setCropBox(Rectangle rectangle)
Sets the CropBox object, that defines the visible region of default user space.
|
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.
|
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.
|
PdfPage |
setPageLabel(PageLabelNumberingStyleConstants numberingStyle, String labelPrefix)
This method adds or replaces a page label.
|
PdfPage |
setPageLabel(PageLabelNumberingStyleConstants numberingStyle, String labelPrefix, int firstPage)
This method adds or replaces a page label.
|
void |
setPageRotationInverseMatrixWritten()
NOTE: For internal usage! Use this method only if you know what you are doing.
|
PdfPage |
setResources(PdfResources pdfResources)
Sets PdfResources object.
|
PdfPage |
setRotation(int degAngle)
Sets the page rotation.
|
PdfPage |
setTrimBox(Rectangle rectangle)
Sets the TrimBox object, that define the intended dimensions of the finished page after trimming.
|
void |
setXmpMetadata(byte[] xmpMetadata)
Sets the XMP Metadata.
|
void |
setXmpMetadata(XMPMeta xmpMeta)
Serializes XMP Metadata to byte array and sets it.
|
void |
setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions)
Serializes XMP Metadata to byte array and sets it.
|
ensureObjectIsAddedToDocument, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
protected PdfPage(PdfDictionary pdfObject)
protected PdfPage(PdfDocument pdfDocument, PageSize pageSize)
protected PdfPage(PdfDocument pdfDocument)
public Rectangle getPageSize()
Rectangle
that specify page size.
public Rectangle getPageSizeWithRotation()
Rectangle
that specify size of rotated page.
public int getRotation()
int
number of degrees. Default value: 0
public PdfPage setRotation(int degAngle)
degAngle
- the int
number of degrees by which the page shall be rotated clockwise when displayed or printed. Shall be a multiple of 90.
PdfPage
instance.
public PdfStream getContentStream(int index)
PdfArray
. The situation when Contents object is a PdfStream
is treated like a one element array.
index
- the int
index of returned PdfStream
.
PdfStream
object at specified index.
IndexOutOfBoundsException
- if the index is out of range
public int getContentStreamCount()
PdfArray
. The situation when Contents object is a PdfStream
is treated like a one element array.
int
size of Contents object, or 1 if Contents object is a PdfStream
.
public PdfStream getFirstContentStream()
PdfStream
in Contents object, or null
if Contents is empty.
public PdfStream getLastContentStream()
PdfStream
in Contents object, or null
if Contents is empty.
public PdfStream newContentStreamBefore()
PdfStream
object and puts it at the beginning of Contents array (if Contents object is PdfStream
it will be replaced with one-element array).
PdfStream
object.
public PdfStream newContentStreamAfter()
PdfStream
object and puts it at the end of Contents array (if Contents object is PdfStream
it will be replaced with one-element array).
PdfStream
object.
public PdfResources getResources()
PdfResources
wrapper 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.
flush()
, or you can add it manually with this line, if needed:
getPdfObject().put(PdfName.Resources, getResources().getPdfObject());
PdfResources
wrapper of the page.
public PdfPage setResources(PdfResources pdfResources)
PdfResources
object.
pdfResources
- PdfResources
to set.
PdfPage
instance.
public void setXmpMetadata(byte[] xmpMetadata) throws IOException
xmpMetadata
- the byte[]
of XMP Metadata to set.
IOException
- in case of writing error.
public void setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions) throws XMPException, IOException
xmpMeta
- the XMPMeta
object to set.
serializeOptions
- the SerializeOptions
used while serialization.
XMPException
- in case of XMP Metadata serialization error.
IOException
- in case of writing error.
public void setXmpMetadata(XMPMeta xmpMeta) throws XMPException, IOException
xmpMeta
- the XMPMeta
object to set.
XMPException
- in case of XMP Metadata serialization error.
IOException
- in case of writing error.
public PdfStream getXmpMetadata() throws XMPException
PdfStream
object, that represent XMP Metadata.
XMPException
public PdfPage copyTo(PdfDocument toDocument)
toDocument
- a document to copy page to.
PdfPage
.
public PdfPage copyTo(PdfDocument toDocument, IPdfPageExtraCopier copier)
toDocument
- a document to copy page to.
copier
- a copier which bears a specific copy logic. May be null
PdfPage
.
public PdfFormXObject copyAsFormXObject(PdfDocument toDocument) throws IOException
toDocument
- a document to copy to.
PdfFormXObject
object.
IOException
public PdfDocument getDocument()
PdfDocument
that owns that page, or null
if such document isn't exist.
PdfDocument
that owns that page, or null
if such document isn't exist.
public void flush()
flush
in class PdfObjectWrapper<PdfDictionary>
public void flush(boolean flushContentStreams)
flushContentStreams
is 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.
PdfPage#flush() method
.
PdfADocument
is used, flushing will be applied only if flushContentStreams
is true.
flushContentStreams
- 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.
public Rectangle getMediaBox()
Rectangle
object specified by page's Media Box, that defines the boundaries of the physical medium on which the page shall be displayed or printed
Rectangle
object specified by page Media Box, expressed in default user space units.
PdfException
- in case of any error while reading MediaBox object.
public PdfPage setMediaBox(Rectangle rectangle)
public Rectangle getCropBox()
Rectangle
specified 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.
Rectangle
object specified by pages's CropBox, expressed in default user space units. MediaBox by default.
public PdfPage setCropBox(Rectangle rectangle)
public PdfPage setArtBox(Rectangle rectangle)
public Rectangle getArtBox()
Rectangle
object 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.
Rectangle
object specified by page's ArtBox, expressed in default user space units. CropBox by default.
public PdfPage setTrimBox(Rectangle rectangle)
public Rectangle getTrimBox()
Rectangle
object specified by page's TrimBox object, that define the intended dimensions of the finished page after trimming.
Rectangle
object specified by page's TrimBox, expressed in default user space units. CropBox by default.
public byte[] getContentBytes()
PdfException
- in case of any {@link IOException).
public byte[] getStreamBytes(int index)
index
- index of stream inside Content.
PdfException
- in case of any {@link IOException).
public int getNextMcid()
PdfException
- in case of not tagged document.
public Integer getStructParentIndex()
Integer
key of the page’s entry in the structural parent tree.
Integer
key of the page’s entry in the structural parent tree.
public PdfPage setAdditionalAction(PdfName key, PdfAction action)
public List<PdfAnnotation> getAnnotations()
List
containing all page's annotations.
public boolean containsAnnotation(PdfAnnotation annotation)
annotation
- the PdfAnnotation
to check.
true
if page contains specified annotation and false
otherwise.
public PdfPage addAnnotation(PdfAnnotation annotation)
annotation
- the PdfAnnotation
to add.
PdfPage
instance.
public PdfPage addAnnotation(int index, PdfAnnotation annotation, boolean tagAnnotation)
PdfAnnotation
to specified index in annotations array with or without autotagging. May be used in chain.
index
- the index at which specified annotation will be added. If -1
then annotation will be added to the end of array.
annotation
- the PdfAnnotation
to add.
tagAnnotation
- if true
the added annotation will be autotagged.
TagStructureContext.getAutoTaggingPointer()
)
PdfPage
instance.
public PdfPage removeAnnotation(PdfAnnotation annotation)
annotation
- an annotation to be removed.
PdfPage
instance.
public int getAnnotsSize()
PdfAnnotation
associated with this page.
int
number of PdfAnnotation
associated with this page.
public List<PdfOutline> getOutlines(boolean updateOutlines)
updateOutlines
-
public boolean isIgnorePageRotationForContent()
public PdfPage setIgnorePageRotationForContent(boolean ignorePageRotationForContent)
false
.
ignorePageRotationForContent
- - true to ignore rotation of the new content on the rotated page.
public PdfPage setPageLabel(PageLabelNumberingStyleConstants numberingStyle, String labelPrefix)
numberingStyle
- The numbering style that shall be used for the numeric portion of each page label. May be NULL
labelPrefix
- The label prefix for page labels in this range. May be NULL
PdfPage
instance.
public PdfPage setPageLabel(PageLabelNumberingStyleConstants numberingStyle, String labelPrefix, int firstPage)
numberingStyle
- The numbering style that shall be used for the numeric portion of each page label. May be NULL
labelPrefix
- The label prefix for page labels in this range. May be NULL
firstPage
- The value of the numeric portion for the first page label in the range. Must be greater or equal 1.
PdfPage
instance.
public PdfPage put(PdfName key, PdfObject value)
PdfDictionary
. May be used in chain.
public boolean isPageRotationInverseMatrixWritten()
setIgnorePageRotationForContent(boolean)
public void setPageRotationInverseMatrixWritten()
setIgnorePageRotationForContent(boolean)
protected boolean isWrappedObjectMustBeIndirect()
PdfObjectWrapper
isWrappedObjectMustBeIndirect
in class PdfObjectWrapper<PdfDictionary>
Copyright © 1998–2016 iText Group NV. All rights reserved.