Skip to content

PDFPage

Namespace: O2S.Components.PDF4NET

Defines a PDF page.

public class PDFPage : PDFContentStreamContainer

Inheritance ObjectPDFContentStreamContainerPDFPage

Constructors

PDFPage()

Initializes a new PDFPage object.

public PDFPage()

PDFPage(PDFPageSize)

Initializes a new PDFPage object.

public PDFPage(PDFPageSize pageSize)

Parameters

pageSize PDFPageSize
Initial page size.


PDFPage(PDFPage)

Initializes a new PDFPage object.

public PDFPage(PDFPage src)

Parameters

src PDFPage


Properties

Annotations

Gets the annotations.

public PDFAnnotationCollection Annotations { get; }

Property Value

PDFAnnotationCollection
The list of annotations associated with the page.


ArtBox

Gets or sets the art box.

public PDFStandardRectangle ArtBox { get; set; }

Property Value

PDFStandardRectangle
A PDFStandardRectangle, 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


BleedBox

Gets or sets the bleed box.

public PDFStandardRectangle BleedBox { get; set; }

Property Value

PDFStandardRectangle
A PDFStandardRectangle, 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.


Canvas

Gets the page canvas.

public PDFPageCanvas Canvas { get; internal set; }

Property Value

PDFPageCanvas
The page canvas surface.


CloseAction

Gets or sets the page close action.

public PDFAction CloseAction { get; set; }

Property Value

PDFAction
An action to be performed when the page is closed (for example, when the user navigates to the next or previous page, or follows a link annotation or outline item).


CosDictionary

Gets the COS dictionary asssociated with this object.

public PDFCosDictionary CosDictionary { get; }

Property Value

PDFCosDictionary
The internal COS dictionary.

Remarks

Incorrect manipulation of the information in the COS dictionary can lead to invalid PDF files.


CropBox

Gets or sets the crop box.

public PDFStandardRectangle CropBox { get; set; }

Property Value

PDFStandardRectangle
A PDFStandardRectangle, expressed in default user space units, defining the visible region of default user space.


Document

Gets the PDF document.

public PDFFixedDocument Document { get; internal set; }

Property Value

PDFFixedDocument
The document in which this page is included.


Fields

Gets the form fields.

public PDFFieldCollection Fields { get; }

Property Value

PDFFieldCollection
The list of form fields associated with the page.


Group

Gets or sets the page group.

public PDFGroupXObject Group { get; set; }

Property Value

PDFGroupXObject
A PDFGroupXObject object that shall specify the attributes of the page's page group for use in the transparent imaging model.


Height

Gets or sets the visual page height.

public double Height { get; set; }

Property Value

Double
The visual height of the page.

Remarks

The visual height is the height of the page as it is seen on the display. It is always measured on vertical no matter the page rotation.


MediaBox

Gets or sets the media box.

public PDFStandardRectangle MediaBox { get; set; }

Property Value

PDFStandardRectangle
A PDFStandardRectangle, expressed in default user space units, defining the boundaries of the physical medium on which the page is intended to be displayed or printed.


OpenAction

Gets or sets the page open action.

public PDFAction OpenAction { get; set; }

Property Value

PDFAction
An action to be performed when the page is opened (for example, when the user navigates to it from the next or previous page or by means of a link annotation or outline item).


OptionalContentGroups

Gets the list of optional content groups included in the page content.

public PDFOptionalContentGroupCollection OptionalContentGroups { get; internal set; }

Property Value

PDFOptionalContentGroupCollection
The list of optional content groups included in the page content

Remarks

This collection is filled automatically with the optional content groups drawn on the page, either when page content is created or when a page is loaded from a source file.


PageSize

Gets or sets the PDF page size to a predefined value.

public PDFPageSize PageSize { get; set; }

Property Value

PDFPageSize
A PDFPageSize object that specifies a predefined page size.

Remarks

The value returned by this property is matched against predefined page sizes within a certain margin (PDFPageSize.Delta) so the Width and Height properties of the returned object might not match the actual page Width and Height.


Rotation

Gets or sets the rotation angle.

public int Rotation { get; set; }

Property Value

Int32
The number of degrees by which the page should be rotated clockwise when displayed or printed.

Exceptions

ArgumentOutOfRangeException
Thrown when the value being set is not one of the accepted values.

Remarks

The accepted values for this property are 0, 90, 180 and 270 degrees.


TabOrder

Gets or sets the annotations tab order.

public PDFPageTabOrder TabOrder { get; set; }

Property Value

PDFPageTabOrder
A PDFPageTabOrder enumeration member specifying the tab order that shall be used for annotations on the page.


TrimBox

Gets or sets the trim box.

public PDFStandardRectangle TrimBox { get; set; }

Property Value

PDFStandardRectangle
A PDFStandardRectangle, expressed in default user space units, defining the intended dimensions of the finished page after trimming.


UserUnit

Gets or sets the page user unit.

public double UserUnit { get; set; }

Property Value

Double
A positive number that shall give the size of default user space units, in multiples of 1/72 inch.

Exceptions

ArgumentOutOfRangeException
Thrown when the value being set is negative or zero.


Viewports

Gets or sets the page viewports.

public PDFViewportCollection Viewports { get; set; }

Property Value

PDFViewportCollection
A collection of viewports defined on the page.


VisibleBox

Gets the box that defines the actual visible area of the page.

public PDFStandardRectangle VisibleBox { get; }

Property Value

PDFStandardRectangle
A PDFStandardRectangle, expressed in default user space units, defining the actual visible region of default user space.


Width

Gets or sets the visual page width.

public double Width { get; set; }

Property Value

Double
The visual width of the page.

Remarks

The visual width is the width of the page as it is seen on the display. It is always measured on horizontal no matter the page rotation.


XmpMetadata

Gets or sets the XMP page metadata.

public PDFXmpMetadata XmpMetadata { get; set; }

Property Value

PDFXmpMetadata
The XMP page metadata.


Methods

ConvertDisplayPointToStandardPoint(PDFPoint)

Converts a point from the visual coordinate system (origin of coordinate system in top left corner of visual page area) to standard PDF coordinate system (origin of coordinate system in bottom left corner of page media box).

public PDFPoint ConvertDisplayPointToStandardPoint(PDFPoint point)

Parameters

point PDFPoint
The point in visual coordinates.

Returns

PDFPoint
The point in standard PDF coodinates.


ConvertDisplayRectangleToStandardRectangle(PDFDisplayRectangle)

Converts a rectangle on the page from visual coordinate system (origin of coordinate system in top left corner of visual page area) to standard PDF coordinate system (origin of coordinate system in bottom left corner of page media box).

public PDFStandardRectangle ConvertDisplayRectangleToStandardRectangle(PDFDisplayRectangle visualRectangle)

Parameters

visualRectangle PDFDisplayRectangle
The rectangle in visual coordinates.

Returns

PDFStandardRectangle
The rectangle in standard PDF coordinates.


ConvertStandardPointToDisplayPoint(PDFPoint)

Converts a point from standard PDF coordinate system (origin of coordinate system in bottom left corner of page media box) to visual coordinate system (origin of coordinate system in top left corner of visual page area).

public PDFPoint ConvertStandardPointToDisplayPoint(PDFPoint point)

Parameters

point PDFPoint
The point in standard PDF coordinates.

Returns

PDFPoint
The point in visual coodinates.


ConvertStandardRectangleToDisplayRectangle(PDFStandardRectangle)

Converts a rectangle on the page from standard PDF coordinate system (origin of coordinate system in bottom left corner of page media box) to visual coordinate system (origin of coordinate system in top left corner of visual page area).

public PDFDisplayRectangle ConvertStandardRectangleToDisplayRectangle(PDFStandardRectangle standardRectangle)

Parameters

standardRectangle PDFStandardRectangle
The rectangle in standard PDF coordinates.

Returns

PDFDisplayRectangle
The rectangle in visual coordinates.


GetPageFonts(Boolean, Boolean)

Gets the set of fonts included in this page.

public HashSet<PDFCosDictionary> GetPageFonts(bool includeEmbeddedFont, bool includeNonEmbeddedFonts)

Parameters

includeEmbeddedFont Boolean
True if the set should include the embedded fonts.

includeNonEmbeddedFonts Boolean
True if the set should include the non-embedded fonts.

Returns

HashSet<PDFCosDictionary>
A set of PDFCosDictionary objects representing the fonts used by this page.

Remarks

This method examines the fonts included in page's resources dictionary. It is possible that not all the fonts are actually used on the page.


LoadGraphics(Boolean)

Loads the page canvas from the source PDF file.

public void LoadGraphics(bool enableAllOperations)

Parameters

enableAllOperations Boolean
If true then all page content streams are loaded so that all operations that process the page content (add new content, text search, redaction, page transforms, etc) can be performed with success. If false then only adding new content to the page is supported.

Remarks

When a PDF file is opened in incremental update mode, the page canvas is not loaded if not specified explicitly. This method allows to load the page canvas on demand only for required pages.
Note: This method can be used only when the document has been loaded from a stream and the stream has been kept open, otherwise an exception will be thrown.


Save()

Saves the PDF page.

public void Save()

Remarks

The page must be included in a document and the save procedure must be already initiated by a PDFFixedDocument.BeginSave(Stream) call.


SaveCanvas()

Saves the page canvas.

public void SaveCanvas()

Remarks

The page canvas can be composed internally of multiple fragments. If you are working with large vector graphics, such as maps, then you can split the page canvas in fragments and save each fragmment as soon as it is done in order to reduce memory consumption. A graphics fragment is automatically created when PDFPageCanvas.Compress() method is called.
The page must be included in a document and the save procedure must be already initiated by a PDFFixedDocument.BeginSave(Stream) call.


SaveImages()

Saves the images drawn on the PDF page.

public void SaveImages()

Remarks

The page must be included in a document and the save procedure must be already initiated by a PDFFixedDocument.BeginSave(Stream) call.


SetCanvasPosition(PDFPageCanvasPosition)

Sets the position of the page canvas relative to existing page content.

public void SetCanvasPosition(PDFPageCanvasPosition canvasPosition)

Parameters

canvasPosition PDFPageCanvasPosition
Position of the page canvas.

Remarks

If the page is newly created this method has no effect since there is no previous content. If the page has been extracted from a PDF file or has been created by loading a PDF file into a PDFFixedDocument then the page canvas can be under the existing page content or on top of existing page content (default).