PDFsharp-net6

PdfPage

Namespace: PdfSharp.Pdf

Represents a page in a PDF document.

public sealed class PdfPage : PdfDictionary, System.ICloneable, System.Collections.Generic.IEnumerable`1[[System.Collections.Generic.KeyValuePair`2[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PdfSharp.Pdf.PdfItem, PdfSharp, Version=0.1.3.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Collections.IEnumerable, PdfSharp.Pdf.Advanced.IContentStream

Inheritance ObjectPdfItemPdfObjectPdfDictionaryPdfPage
Implements ICloneable, IEnumerable<KeyValuePair<String, PdfItem>>, IEnumerable, IContentStream

Properties

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

Object

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

PageOrientation

Size

Gets or sets one of the predefined standard sizes like.

public PageSize Size { get; set; }

Property Value

PageSize

TrimMargins

Gets or sets the trim margins.

public TrimMargins TrimMargins { get; set; }

Property Value

TrimMargins

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

PdfRectangle

CropBox

Gets or sets the crop box.

public PdfRectangle CropBox { get; set; }

Property Value

PdfRectangle

BleedBox

Gets or sets the bleed box.

public PdfRectangle BleedBox { get; set; }

Property Value

PdfRectangle

ArtBox

Gets or sets the art box.

public PdfRectangle ArtBox { get; set; }

Property Value

PdfRectangle

TrimBox

Gets or sets the trim box.

public PdfRectangle TrimBox { get; set; }

Property Value

PdfRectangle

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

XUnit

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

XUnit

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

Int32

Contents

Gets the array of content streams of the page.

public PdfContents Contents { get; }

Property Value

PdfContents

HasAnnotations

Gets the annotations array of this page.

public bool HasAnnotations { get; }

Property Value

Boolean

Annotations

Gets the annotations array of this page.

public PdfAnnotations Annotations { get; }

Property Value

PdfAnnotations

CustomValues

Gets or sets the custom values.

public PdfCustomValues CustomValues { get; set; }

Property Value

PdfCustomValues

Resources

Gets the PdfResources object of this page.

public PdfResources Resources { get; }

Property Value

PdfResources

Elements

Gets the dictionary containing the elements of this dictionary.

public DictionaryElements Elements { get; }

Property Value

DictionaryElements

Stream

Gets or sets the PDF stream belonging to this dictionary. Returns null if the dictionary has no stream. To create the stream, call the CreateStream function.

public PdfStream Stream { get; set; }

Property Value

PdfStream

Owner

Gets the PdfDocument this object belongs to.

public PdfDocument Owner { get; }

Property Value

PdfDocument

IsIndirect

Indicates whether the object is an indirect object.

public bool IsIndirect { get; }

Property Value

Boolean

Internals

Gets the PdfInternals object of this document, that grants access to some internal structures which are not part of the public interface of PdfDocument.

public PdfObjectInternals Internals { get; }

Property Value

PdfObjectInternals

Reference

Gets the indirect reference of this object. If the value is null, this object is a direct object.

public PdfReference Reference { get; internal set; }

Property Value

PdfReference

ReferenceNotNull

Gets the indirect reference of this object. Throws if it is null.

public PdfReference ReferenceNotNull { get; }

Property Value

PdfReference

Exceptions

InvalidOperationException
The indirect reference must be not null here.

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 PdfDocument
The document.

Methods

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()

AddDocumentLink(PdfRectangle, Int32)

Adds an internal document link.

public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, int destinationPage)

Parameters

rect PdfRectangle
The link area in default page coordinates.

destinationPage Int32
The destination page.

Returns

PdfLinkAnnotation

AddDocumentLink(PdfRectangle, String)

Adds an internal document link.

public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string destinationName)

Parameters

rect PdfRectangle
The link area in default page coordinates.

destinationName String
The Named Destination’s name.

Returns

PdfLinkAnnotation

AddDocumentLink(PdfRectangle, String, String, Nullable<Boolean>)

Adds an external document link.

public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string documentPath, string destinationName, Nullable<bool> newWindow)

Parameters

rect PdfRectangle
The link area in default page coordinates.

documentPath String
The path to the target document.

destinationName String
The Named Destination’s name in the target document.

newWindow Nullable<Boolean>
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

PdfLinkAnnotation

AddEmbeddedDocumentLink(PdfRectangle, String, Nullable<Boolean>)

Adds an embedded document link.

public PdfLinkAnnotation AddEmbeddedDocumentLink(PdfRectangle rect, string destinationPath, Nullable<bool> newWindow)

Parameters

rect PdfRectangle
The link area in default page coordinates.

destinationPath String
The 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 Nullable<Boolean>
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

PdfLinkAnnotation

AddEmbeddedDocumentLink(PdfRectangle, String, String, Nullable<Boolean>)

Adds an external embedded document link.

public PdfLinkAnnotation AddEmbeddedDocumentLink(PdfRectangle rect, string documentPath, string destinationPath, Nullable<bool> newWindow)

Parameters

rect PdfRectangle
The link area in default page coordinates.

documentPath String
The path to the target document.

destinationPath String
The 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 Nullable<Boolean>
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

PdfLinkAnnotation

AddWebLink(PdfRectangle, String)

Adds a link to the Web.

public PdfLinkAnnotation AddWebLink(PdfRectangle rect, string url)

Parameters

rect PdfRectangle
The rect.

url String
The URL.

Returns

PdfLinkAnnotation

AddFileLink(PdfRectangle, String)

Adds a link to a file.

public PdfLinkAnnotation AddFileLink(PdfRectangle rect, string fileName)

Parameters

rect PdfRectangle
The rect.

fileName String
Name of the file.

Returns

PdfLinkAnnotation

GetFontName(XFont, PdfFont&)

Gets the resource name of the specified font within this page.

internal string GetFontName(XFont font, PdfFont& pdfFont)

Parameters

font XFont

pdfFont PdfFont&

Returns

String

TryGetFontName(String, PdfFont&)

Tries to get the resource name of the specified font data within this page. Returns null if no such font exists.

internal string TryGetFontName(string idName, PdfFont& pdfFont)

Parameters

idName String

pdfFont PdfFont&

Returns

String

GetFontName(String, Byte[], PdfFont&)

Gets the resource name of the specified font data within this page.

internal string GetFontName(string idName, Byte[] fontData, PdfFont& pdfFont)

Parameters

idName String

fontData Byte[]

pdfFont PdfFont&

Returns

String

GetImageName(XImage)

Gets the resource name of the specified image within this page.

internal string GetImageName(XImage image)

Parameters

image XImage

Returns

String

GetFormName(XForm)

Gets the resource name of the specified form within this page.

internal string GetFormName(XForm form)

Parameters

form XForm

Returns

String

WriteObject(PdfWriter)

internal void WriteObject(PdfWriter writer)

Parameters

writer PdfWriter

InheritValues(PdfDictionary, InheritedValues)

Inherit values from parent node.

internal static void InheritValues(PdfDictionary page, InheritedValues values)

Parameters

page PdfDictionary

values InheritedValues

InheritValues(PdfDictionary, InheritedValues&)

Add all inheritable values from the specified page to the specified values structure.

internal static void InheritValues(PdfDictionary page, InheritedValues& values)

Parameters

page PdfDictionary

values InheritedValues&

PrepareForSave()

internal void PrepareForSave()