Class PdfPage
Represents a page in a PDF document.
public sealed class PdfPage : PdfDictionary, ICloneable, IEnumerable<KeyValuePair<string, PdfItem?>>, IEnumerable
- Inheritance
-
PdfPage
- Implements
- Inherited Members
Constructors
PdfPage()
Initializes a new page. The page must be added to a document before it can be used. Depending on the IsMetric property of the current region the page size is set to A4 or Letter respectively. If this size is not appropriate it should be changed before any drawing operations are performed on the page.
public PdfPage()
PdfPage(PdfDocument)
Initializes a new instance of the PdfPage class.
public PdfPage(PdfDocument document)
Parameters
document
PdfDocumentThe document.
Properties
Annotations
Gets the annotations array of this page.
public PdfAnnotations Annotations { get; }
Property Value
ArtBox
Gets or sets the art box.
public PdfRectangle ArtBox { get; set; }
Property Value
BleedBox
Gets or sets the bleed box.
public PdfRectangle BleedBox { get; set; }
Property Value
Contents
Gets the array of content streams of the page.
public PdfContents Contents { get; }
Property Value
CropBox
Gets or sets the crop box.
public PdfRectangle CropBox { get; set; }
Property Value
CustomValues
Gets or sets the custom values.
public PdfCustomValues CustomValues { get; set; }
Property Value
HasAnnotations
Gets the annotations array of this page.
public bool HasAnnotations { get; }
Property Value
Height
Gets or sets the height of the page. If orientation is Landscape, this function applies to the width.
public XUnit Height { get; set; }
Property Value
MediaBox
Gets or sets the media box directly. XGraphics is not prepared to work with a media box with an origin other than (0,0).
public PdfRectangle MediaBox { get; set; }
Property Value
Orientation
Gets or sets the orientation of the page. The default value PageOrientation.Portrait. If an imported page has a /Rotate value that matches the formula 90 + n * 180 the orientation is set to PageOrientation.Landscape.
public PageOrientation Orientation { get; set; }
Property Value
Resources
Gets the PdfResources object of this page.
public PdfResources Resources { get; }
Property Value
Rotate
Gets or sets the /Rotate entry of the PDF page. The value is the number of degrees by which the page should be rotated clockwise when displayed or printed. The value must be a multiple of 90. PDFsharp does not set this value, but for imported pages this value can be set and must be taken into account when adding graphic to such a page.
public int Rotate { get; set; }
Property Value
Size
Gets or sets one of the predefined standard sizes like.
public PageSize Size { get; set; }
Property Value
Tag
Gets or sets a user defined object that contains arbitrary information associated with this PDF page. The tag is not used by PDFsharp.
public object? Tag { get; set; }
Property Value
TrimBox
Gets or sets the trim box.
public PdfRectangle TrimBox { get; set; }
Property Value
TrimMargins
Gets or sets the trim margins.
public TrimMargins TrimMargins { get; set; }
Property Value
Width
Gets or sets the width of the page. If orientation is Landscape, this function applies to the height.
public XUnit Width { get; set; }
Property Value
Methods
AddDocumentLink(PdfRectangle, int, XPoint?)
Adds an internal document link.
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, int destinationPage, XPoint? point = null)
Parameters
rect
PdfRectangleThe link area in default page coordinates.
destinationPage
intThe destination page.
point
XPoint?The position in the destination page.
Returns
AddDocumentLink(PdfRectangle, string)
Adds an internal document link.
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string destinationName)
Parameters
rect
PdfRectangleThe link area in default page coordinates.
destinationName
stringThe Named Destination’s name.
Returns
AddDocumentLink(PdfRectangle, string, string, bool?)
Adds an external document link.
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string documentPath, string destinationName, bool? newWindow = null)
Parameters
rect
PdfRectangleThe link area in default page coordinates.
documentPath
stringThe path to the target document.
destinationName
stringThe Named Destination’s name in the target document.
newWindow
bool?True, if the destination document shall be opened in a new window. If not set, the viewer application should behave in accordance with the current user preference.
Returns
AddEmbeddedDocumentLink(PdfRectangle, string, bool?)
Adds an embedded document link.
public PdfLinkAnnotation AddEmbeddedDocumentLink(PdfRectangle rect, string destinationPath, bool? newWindow = null)
Parameters
rect
PdfRectangleThe link area in default page coordinates.
destinationPath
stringThe path to the named destination through the embedded documents. The path is separated by '' and the last segment is the name of the named destination. The other segments describe the route from the current (root or embedded) document to the embedded document holding the destination. ".." references to the parent, other strings refer to a child with this name in the EmbeddedFiles name dictionary.
newWindow
bool?True, if the destination document shall be opened in a new window. If not set, the viewer application should behave in accordance with the current user preference.
Returns
AddEmbeddedDocumentLink(PdfRectangle, string, string, bool?)
Adds an external embedded document link.
public PdfLinkAnnotation AddEmbeddedDocumentLink(PdfRectangle rect, string documentPath, string destinationPath, bool? newWindow = null)
Parameters
rect
PdfRectangleThe link area in default page coordinates.
documentPath
stringThe path to the target document.
destinationPath
stringThe path to the named destination through the embedded documents in the target document. The path is separated by '' and the last segment is the name of the named destination. The other segments describe the route from the root document to the embedded document. Each segment name refers to a child with this name in the EmbeddedFiles name dictionary.
newWindow
bool?True, if the destination document shall be opened in a new window. If not set, the viewer application should behave in accordance with the current user preference.
Returns
AddFileLink(PdfRectangle, string)
Adds a link to a file.
public PdfLinkAnnotation AddFileLink(PdfRectangle rect, string fileName)
Parameters
rect
PdfRectangleThe rect.
fileName
stringName of the file.
Returns
AddWebLink(PdfRectangle, string)
Adds a link to the Web.
public PdfLinkAnnotation AddWebLink(PdfRectangle rect, string url)
Parameters
rect
PdfRectangleThe rect.
url
stringThe URL.
Returns
Close()
Closes the page. A closed page cannot be modified anymore, and it is not possible to get an XGraphics object for a closed page. Closing a page is not required, but may save resources if the document has many pages.
public void Close()