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 Object → PdfItem → PdfObject → PdfDictionary → PdfPage
Implements ICloneable, IEnumerable<KeyValuePair<String, PdfItem>>, IEnumerable, IContentStream
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; }
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; }
Gets or sets one of the predefined standard sizes like.
public PageSize Size { get; set; }
Gets or sets the trim margins.
public TrimMargins TrimMargins { get; set; }
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; }
Gets or sets the crop box.
public PdfRectangle CropBox { get; set; }
Gets or sets the bleed box.
public PdfRectangle BleedBox { get; set; }
Gets or sets the art box.
public PdfRectangle ArtBox { get; set; }
Gets or sets the trim box.
public PdfRectangle TrimBox { get; set; }
Gets or sets the height of the page. If orientation is Landscape, this function applies to the width.
public XUnit Height { get; set; }
Gets or sets the width of the page. If orientation is Landscape, this function applies to the height.
public XUnit Width { get; set; }
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; }
Gets the array of content streams of the page.
public PdfContents Contents { get; }
Gets the annotations array of this page.
public bool HasAnnotations { get; }
Gets the annotations array of this page.
public PdfAnnotations Annotations { get; }
Gets or sets the custom values.
public PdfCustomValues CustomValues { get; set; }
Gets the PdfResources object of this page.
public PdfResources Resources { get; }
Gets the dictionary containing the elements of this dictionary.
public DictionaryElements Elements { get; }
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; }
Gets the PdfDocument this object belongs to.
public PdfDocument Owner { get; }
Indicates whether the object is an indirect object.
public bool IsIndirect { get; }
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; }
Gets the indirect reference of this object. If the value is null, this object is a direct object.
public PdfReference Reference { get; internal set; }
Gets the indirect reference of this object. Throws if it is null.
public PdfReference ReferenceNotNull { get; }
InvalidOperationException
The indirect reference must be not null here.
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()
Initializes a new instance of the PdfPage class.
public PdfPage(PdfDocument document)
document
PdfDocument
The document.
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()
Adds an internal document link.
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, int destinationPage)
rect
PdfRectangle
The link area in default page coordinates.
destinationPage
Int32
The destination page.
Adds an internal document link.
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string destinationName)
rect
PdfRectangle
The link area in default page coordinates.
destinationName
String
The Named Destination’s name.
Adds an external document link.
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string documentPath, string destinationName, Nullable<bool> newWindow)
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.
Adds an embedded document link.
public PdfLinkAnnotation AddEmbeddedDocumentLink(PdfRectangle rect, string destinationPath, Nullable<bool> newWindow)
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.
Adds an external embedded document link.
public PdfLinkAnnotation AddEmbeddedDocumentLink(PdfRectangle rect, string documentPath, string destinationPath, Nullable<bool> newWindow)
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.
Adds a link to the Web.
public PdfLinkAnnotation AddWebLink(PdfRectangle rect, string url)
rect
PdfRectangle
The rect.
url
String
The URL.
Adds a link to a file.
public PdfLinkAnnotation AddFileLink(PdfRectangle rect, string fileName)
rect
PdfRectangle
The rect.
fileName
String
Name of the file.
Gets the resource name of the specified font within this page.
internal string GetFontName(XFont font, PdfFont& pdfFont)
font
XFont
pdfFont
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)
idName
String
pdfFont
PdfFont&
Gets the resource name of the specified font data within this page.
internal string GetFontName(string idName, Byte[] fontData, PdfFont& pdfFont)
idName
String
fontData
Byte[]
pdfFont
PdfFont&
Gets the resource name of the specified image within this page.
internal string GetImageName(XImage image)
image
XImage
Gets the resource name of the specified form within this page.
internal string GetFormName(XForm form)
form
XForm
internal void WriteObject(PdfWriter writer)
writer
PdfWriter
Inherit values from parent node.
internal static void InheritValues(PdfDictionary page, InheritedValues values)
page
PdfDictionary
values
InheritedValues
Add all inheritable values from the specified page to the specified values structure.
internal static void InheritValues(PdfDictionary page, InheritedValues& values)
page
PdfDictionary
values
InheritedValues&
internal void PrepareForSave()