Class PdfPage
public class PdfPage : PdfObjectWrapper<PdfDictionary>
- Inheritance
-
PdfPage
- Inherited Members
Constructors
PdfPage(PdfDictionary)
protected PdfPage(PdfDictionary pdfObject)
Parameters
pdfObject
PdfDictionary
PdfPage(PdfDocument)
protected PdfPage(PdfDocument pdfDocument)
Parameters
pdfDocument
PdfDocument
PdfPage(PdfDocument, PageSize)
protected PdfPage(PdfDocument pdfDocument, PageSize pageSize)
Parameters
pdfDocument
PdfDocumentpageSize
PageSize
Methods
AddAnnotation(int, PdfAnnotation, bool)
Adds specified PdfAnnotation to specified index in annotations array with or without autotagging.
public virtual PdfPage AddAnnotation(int index, PdfAnnotation annotation, bool tagAnnotation)
Parameters
index
intthe index at which specified annotation will be added. If
-1
then annotation will be added to the end of array.annotation
PdfAnnotationthe PdfAnnotation to add.
tagAnnotation
boolif true the added annotation will be autotagged.
(see GetAutoTaggingPointer() )
Returns
Remarks
Adds specified PdfAnnotation to specified index in annotations array with or without autotagging. May be used in chain.
AddAnnotation(PdfAnnotation)
Adds specified annotation to the end of annotations array and tagged it.
public virtual PdfPage AddAnnotation(PdfAnnotation annotation)
Parameters
annotation
PdfAnnotationthe PdfAnnotation to add.
Returns
Remarks
Adds specified annotation to the end of annotations array and tagged it. May be used in chain.
AddAssociatedFile(string, PdfFileSpec)
Adds file associated with PDF page and identifies the relationship between them.
public virtual void AddAssociatedFile(string description, PdfFileSpec fs)
Parameters
description
stringthe file description
fs
PdfFileSpecfile specification dictionary of associated file
Remarks
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 keyAddAssociatedFile(PdfFileSpec)
public virtual void AddAssociatedFile(PdfFileSpec fs)
Parameters
fs
PdfFileSpecfile specification dictionary of associated file
Remarks
AddOutputIntent(PdfOutputIntent)
Adds PdfOutputIntent that shall specify the colour characteristics of output devices on which the page might be rendered.
public virtual PdfPage AddOutputIntent(PdfOutputIntent outputIntent)
Parameters
outputIntent
PdfOutputIntentPdfOutputIntent to add.
Returns
- See Also
ContainsAnnotation(PdfAnnotation)
Checks if page contains the specified annotation.
public virtual bool ContainsAnnotation(PdfAnnotation annotation)
Parameters
annotation
PdfAnnotationthe PdfAnnotation to check.
Returns
CopyAsFormXObject(PdfDocument)
Copies page as FormXObject to the specified document.
public virtual PdfFormXObject CopyAsFormXObject(PdfDocument toDocument)
Parameters
toDocument
PdfDocumenta document to copy to.
Returns
- PdfFormXObject
copied PdfFormXObject object.
CopyTo(PdfDocument)
Copies page to the specified document.
public virtual PdfPage CopyTo(PdfDocument toDocument)
Parameters
toDocument
PdfDocumenta document to copy page to.
Returns
Remarks
Copies page to the specified document.
NOTE: Works only for pages from the document opened in reading mode, otherwise an exception is thrown.
CopyTo(PdfDocument, IPdfPageExtraCopier)
Copies page to the specified document.
public virtual PdfPage CopyTo(PdfDocument toDocument, IPdfPageExtraCopier copier)
Parameters
toDocument
PdfDocumenta document to copy page to.
copier
IPdfPageExtraCopiera copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier for the same output document.
Returns
Remarks
Copies page to the specified document.
NOTE: Works only for pages from the document opened in reading mode, otherwise an exception is thrown.
CopyTo(PdfDocument, IPdfPageExtraCopier, bool, int)
Copies page and adds it to the specified document to the end or by index if the corresponding parameter is true.
public virtual PdfPage CopyTo(PdfDocument toDocument, IPdfPageExtraCopier copier, bool addPageToDocument, int pageInsertIndex)
Parameters
toDocument
PdfDocumenta document to copy page to.
copier
IPdfPageExtraCopiera copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier for the same output document.
addPageToDocument
booltrue if page should be added to document.
pageInsertIndex
intposition 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
Remarks
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 the
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.
Flush()
Flushes page dictionary, its content streams, annotations and thumb image.
public override void Flush()
Remarks
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.Flush(bool)
Flushes page dictionary, its content streams, annotations and thumb image.
public virtual void Flush(bool flushResourcesContentStreams)
Parameters
flushResourcesContentStreams
boolif 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.
Remarks
Flushes page dictionary, its content streams, annotations and thumb image. If flushResourcesContentStreams
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.
PdfADocument
is used, flushing will be applied only if flushResourcesContentStreams
is 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.
GetAnnotations()
Gets array of annotation dictionaries that shall contain indirect references to all annotations associated with the page.
public virtual IList<PdfAnnotation> GetAnnotations()
Returns
- IList<PdfAnnotation>
the
< PdfAnnotation containing all page's annotations.
GetAnnotsSize()
Gets the number of PdfAnnotation associated with this page.
public virtual int GetAnnotsSize()
Returns
- int
the
int
number of PdfAnnotation associated with this page.
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.
public virtual Rectangle GetArtBox()
Returns
- Rectangle
the Rectangle object specified by page's ArtBox, expressed in default user space units. CropBox by default.
GetAssociatedFiles(bool)
Returns files associated with PDF page.
public virtual PdfArray GetAssociatedFiles(bool create)
Parameters
create
booldefines whether AF arrays will be created if it doesn't exist
Returns
- PdfArray
associated files array
GetBleedBox()
Gets the Rectangle object 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.
public virtual Rectangle GetBleedBox()
Returns
- Rectangle
the Rectangle object specified by page's BleedBox, expressed in default user space units. CropBox by default.
GetContentBytes()
Get decoded bytes for the whole page content.
public virtual byte[] GetContentBytes()
Returns
- byte[]
byte array.
GetContentStream(int)
Gets the content stream at specified 0-based index in the Contents object PdfArray.
public virtual PdfStream GetContentStream(int index)
Parameters
Returns
- PdfStream
PdfStream object at specified index; will return null in case page dictionary doesn't adhere to the specification, meaning that the document is an invalid PDF.
Remarks
Gets the content stream at specified 0-based index in the Contents object PdfArray. The situation when Contents object is a PdfStream is treated like a one element array.
GetContentStreamCount()
Gets the size of Contents object PdfArray.
public virtual int GetContentStreamCount()
Returns
Remarks
Gets the size of Contents object PdfArray. The situation when Contents object is a PdfStream is treated like a one element array.
GetCropBox()
Gets the Rectangle specified by page's CropBox, that defines the visible region of default user space.
public virtual Rectangle GetCropBox()
Returns
- Rectangle
the Rectangle object specified by pages's CropBox, expressed in default user space units. MediaBox by default.
Remarks
Gets the 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.
GetDocument()
Gets the PdfDocument that owns that page, or null if such document isn't exist.
public virtual PdfDocument GetDocument()
Returns
- PdfDocument
PdfDocument that owns that page, or null if such document isn't exist.
GetFirstContentStream()
public virtual PdfStream GetFirstContentStream()
Returns
GetLastContentStream()
public virtual PdfStream GetLastContentStream()
Returns
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
public virtual Rectangle GetMediaBox()
Returns
GetNextMcid()
Calculates and returns the next available for this page's content stream MCID reference.
public virtual int GetNextMcid()
Returns
- int
calculated MCID reference.
GetOutlines(bool)
This method gets outlines of a current page
public virtual IList<PdfOutline> GetOutlines(bool updateOutlines)
Parameters
updateOutlines
boolif the flag is true , the method reads the whole document and creates outline tree. If the flag is false , the method gets cached outline tree (if it was cached via calling getOutlines method before).
Returns
- IList<PdfOutline>
return all outlines of a current page
GetPageSize()
Gets page size, defined by media box object.
public virtual Rectangle GetPageSize()
Returns
Remarks
Gets page size, defined by media box object. This method doesn't take page rotation into account.
GetPageSizeWithRotation()
Gets page size, considering page rotation.
public virtual Rectangle GetPageSizeWithRotation()
Returns
GetResources()
Gets the PdfResources wrapper object for this page resources.
public virtual PdfResources GetResources()
Returns
- PdfResources
PdfResources wrapper of the page.
Remarks
Gets the
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.
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 on
Flush()
,
or you can add it manually with this line, if needed:
getPdfObject().put(PdfName.Resources, getResources().getPdfObject());
GetRotation()
Gets the number of degrees by which the page shall be rotated clockwise when displayed or printed.
public virtual int GetRotation()
Returns
- int
int
number of degrees. Default value: 0
Remarks
Gets the number of degrees by which the page shall be rotated clockwise when displayed or printed. Shall be a multiple of 90.
GetStreamBytes(int)
Gets decoded bytes of a certain stream of a page content.
public virtual byte[] GetStreamBytes(int index)
Parameters
index
intindex of stream inside Content.
Returns
- byte[]
byte array.
GetStructParentIndex()
Gets the key of the page’s entry in the structural parent tree.
public virtual int GetStructParentIndex()
Returns
- int
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.
GetTabOrder()
Gets a name specifying the tab order that shall be used for annotations on the page.
public virtual PdfName GetTabOrder()
Returns
Remarks
Gets a name specifying the tab order that shall be used for annotations on the page. The possible values are R (row order), C (column order), and S (structure order). Beginning with PDF 2.0, the possible values also include A (annotations array order) and W (widget order). See ISO 32000 12.5, "Annotations" for details.
GetThumbnailImage()
Sets a stream object that shall define the page’s thumbnail image.
public virtual PdfImageXObject GetThumbnailImage()
Returns
- PdfImageXObject
the thumbnail image, or
null
if it is not present
Remarks
Sets a stream object that shall define the page’s thumbnail image. Thumbnail images represent the contents of its pages in miniature form
GetTrimBox()
Gets the Rectangle object specified by page's TrimBox object, that define the intended dimensions of the finished page after trimming.
public virtual Rectangle GetTrimBox()
Returns
- Rectangle
the Rectangle object specified by page's TrimBox, expressed in default user space units. CropBox by default.
GetXmpMetadata()
Gets the XMP Metadata object.
public virtual PdfStream GetXmpMetadata()
Returns
IsIgnorePageRotationForContent()
public virtual bool IsIgnorePageRotationForContent()
Returns
- bool
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.
IsPageRotationInverseMatrixWritten()
This flag is meaningful for the case, when page rotation is applied and ignorePageRotationForContent is set to true.
public virtual bool IsPageRotationInverseMatrixWritten()
Returns
- bool
true, if inverse matrix is already applied, false otherwise.
Remarks
This flag is meaningful for the case, when page rotation is applied and ignorePageRotationForContent
is set to true. NOTE: It is needed for the internal usage.
This flag defines if 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.
See
SetIgnorePageRotationForContent(bool)
IsWrappedObjectMustBeIndirect()
protected override bool IsWrappedObjectMustBeIndirect()
Returns
NewContentStreamAfter()
Creates new PdfStream object and puts it at the end of Contents array (if Contents object is PdfStream it will be replaced with one-element array).
public virtual PdfStream NewContentStreamAfter()
Returns
NewContentStreamBefore()
Creates new PdfStream object and puts it at the beginning of Contents array (if Contents object is PdfStream it will be replaced with one-element array).
public virtual PdfStream NewContentStreamBefore()
Returns
Put(PdfName, PdfObject)
Helper method that associates specified value with the specified key in the underlying PdfDictionary.
public virtual PdfPage Put(PdfName key, PdfObject value)
Parameters
key
PdfNamethe PdfName key with which the specified value is to be associated
value
PdfObjectthe PdfObject value to be associated with the specified key.
Returns
Remarks
Helper method that associates specified value with the specified key in the underlying PdfDictionary . Can be used in method chaining.
Remove(PdfName)
Helper method that removes the value associated with the specified key from the underlying PdfDictionary.
public virtual PdfPage Remove(PdfName key)
Parameters
Returns
Remarks
Helper method that removes the value associated with the specified key from the underlying PdfDictionary . Can be used in method chaining.
RemoveAnnotation(PdfAnnotation)
Removes an annotation from the page.
public virtual PdfPage RemoveAnnotation(PdfAnnotation annotation)
Parameters
annotation
PdfAnnotationan annotation to be removed
Returns
Remarks
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.RemoveAnnotation(PdfAnnotation, bool)
Removes an annotation from the page.
public virtual PdfPage RemoveAnnotation(PdfAnnotation annotation, bool rememberTagPointer)
Parameters
annotation
PdfAnnotationan annotation to be removed
rememberTagPointer
boolif set to true, the GetAutoTaggingPointer() instance of TagTreePointer will 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
Remarks
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.SetAdditionalAction(PdfName, PdfAction)
Helper method to add an additional action to this page.
public virtual PdfPage SetAdditionalAction(PdfName key, PdfAction action)
Parameters
key
PdfNamea PdfName specifying the name of an additional action
action
PdfActionthe PdfAction to add as an additional action
Returns
Remarks
Helper method to add an additional action to this page. May be used in chain.
SetArtBox(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.
public virtual PdfPage SetArtBox(Rectangle rectangle)
Parameters
Returns
SetBleedBox(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.
public virtual PdfPage SetBleedBox(Rectangle rectangle)
Parameters
Returns
SetCropBox(Rectangle)
Sets the CropBox object, that defines the visible region of default user space.
public virtual PdfPage SetCropBox(Rectangle rectangle)
Parameters
Returns
Remarks
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.
SetIgnorePageRotationForContent(bool)
If true - defines that in case the page has a rotation, then new content will be automatically rotated in the opposite direction.
public virtual PdfPage SetIgnorePageRotationForContent(bool ignorePageRotationForContent)
Parameters
ignorePageRotationForContent
bool- true to ignore rotation of the new content on the rotated page.
Returns
Remarks
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.
SetMediaBox(Rectangle)
Sets the Media Box object, that defines the boundaries of the physical medium on which the page shall be displayed or printed.
public virtual PdfPage SetMediaBox(Rectangle rectangle)
Parameters
Returns
SetPageLabel(PageLabelNumberingStyle?, string)
This method adds or replaces a page label.
public virtual PdfPage SetPageLabel(PageLabelNumberingStyle? numberingStyle, string labelPrefix)
Parameters
numberingStyle
PageLabelNumberingStyle?The numbering style that shall be used for the numeric portion of each page label. May be NULL
labelPrefix
stringThe label prefix for page labels in this range. May be NULL
Returns
SetPageLabel(PageLabelNumberingStyle?, string, int)
This method adds or replaces a page label.
public virtual PdfPage SetPageLabel(PageLabelNumberingStyle? numberingStyle, string labelPrefix, int firstPage)
Parameters
numberingStyle
PageLabelNumberingStyle?The numbering style that shall be used for the numeric portion of each page label. May be NULL
labelPrefix
stringThe label prefix for page labels in this range. May be NULL
firstPage
intThe value of the numeric portion for the first page label in the range. Must be greater or equal 1.
Returns
SetPageRotationInverseMatrixWritten()
NOTE: For internal usage! Use this method only if you know what you are doing.
public virtual void SetPageRotationInverseMatrixWritten()
Remarks
NOTE: For internal usage! Use this method only if you know what you are doing.
This method is called when 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.
See
SetIgnorePageRotationForContent(bool)
SetResources(PdfResources)
Sets PdfResources object.
public virtual PdfPage SetResources(PdfResources pdfResources)
Parameters
pdfResources
PdfResourcesPdfResources to set.
Returns
SetRotation(int)
Sets the page rotation.
public virtual PdfPage SetRotation(int degAngle)
Parameters
degAngle
intthe
int
number of degrees by which the page shall be rotated clockwise when displayed or printed. Shall be a multiple of 90.
Returns
SetTabOrder(PdfName)
Sets a name specifying the tab order that shall be used for annotations on the page.
public virtual PdfPage SetTabOrder(PdfName tabOrder)
Parameters
tabOrder
PdfNamea PdfName specifying the annotations tab order. See method description for the allowed values.
Returns
Remarks
Sets a name specifying the tab order that shall be used for annotations on the page. The possible values are R (row order), C (column order), and S (structure order). Beginning with PDF 2.0, the possible values also include A (annotations array order) and W (widget order). See ISO 32000 12.5, "Annotations" for details.
SetThumbnailImage(PdfImageXObject)
Sets a stream object that shall define the page’s thumbnail image.
public virtual PdfPage SetThumbnailImage(PdfImageXObject thumb)
Parameters
thumb
PdfImageXObjectthe thumbnail image
Returns
Remarks
Sets a stream object that shall define the page’s thumbnail image. Thumbnail images represent the contents of its pages in miniature form
SetTrimBox(Rectangle)
Sets the TrimBox object, that define the intended dimensions of the finished page after trimming.
public virtual PdfPage SetTrimBox(Rectangle rectangle)
Parameters
Returns
SetXmpMetadata(byte[])
Sets the XMP Metadata.
public virtual PdfPage SetXmpMetadata(byte[] xmpMetadata)
Parameters
xmpMetadata
byte[]the
byte[]
of XMP Metadata to set.
Returns
SetXmpMetadata(XMPMeta)
Serializes XMP Metadata to byte array and sets it.
public virtual PdfPage SetXmpMetadata(XMPMeta xmpMeta)
Parameters
Returns
Remarks
Serializes XMP Metadata to byte array and sets it. Uses padding equals to 2000.
SetXmpMetadata(XMPMeta, SerializeOptions)
Serializes XMP Metadata to byte array and sets it.
public virtual PdfPage SetXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions)
Parameters
xmpMeta
XMPMetathe XMPMeta object to set.
serializeOptions
SerializeOptionsthe SerializeOptions used while serialization.