PDFsharp-net6

XPdfForm

Namespace: PdfSharp.Drawing

Represents a so called ‘PDF form external object’, which is typically an imported page of an external PDF document. XPdfForm objects are used like images to draw an existing PDF page of an external document in the current document. XPdfForm objects can only be placed in PDF documents. If you try to draw them using a XGraphics based on an GDI+ context no action is taken if no placeholder image is specified. Otherwise, the place holder is drawn.

public class XPdfForm : XForm, System.IDisposable, PdfSharp.Pdf.Advanced.IContentStream

Inheritance ObjectXImageXFormXPdfForm
Implements IDisposable, IContentStream

Properties

PlaceHolder

Gets or sets an image that is used for drawing if the current XGraphics object cannot handle PDF forms. A place holder is useful for showing a preview of a page on the display, because PDFsharp cannot render native PDF objects.

public XImage PlaceHolder { get; set; }

Property Value

XImage

Page

Gets the underlying PdfPage (if one exists).

public PdfPage Page { get; }

Property Value

PdfPage

PageCount

Gets the number of pages in the PDF form.

public int PageCount { get; }

Property Value

Int32

Width

Caution

Use either PixelWidth or PointWidth. Temporarily obsolete because of rearrangements for WPF.


Gets the width in point of the page identified by the property PageNumber.

public double Width { get; }

Property Value

Double

Height

Caution

Use either PixelHeight or PointHeight. Temporarily obsolete because of rearrangements for WPF.


Gets the height in point of the page identified by the property PageNumber.

public double Height { get; }

Property Value

Double

PointWidth

Gets the width in point of the page identified by the property PageNumber.

public double PointWidth { get; }

Property Value

Double

PointHeight

Gets the height in point of the page identified by the property PageNumber.

public double PointHeight { get; }

Property Value

Double

PixelWidth

Gets the width in point of the page identified by the property PageNumber.

public int PixelWidth { get; }

Property Value

Int32

PixelHeight

Gets the height in point of the page identified by the property PageNumber.

public int PixelHeight { get; }

Property Value

Int32

Size

Get the size of the page identified by the property PageNumber.

public XSize Size { get; }

Property Value

XSize

Transform

Gets or sets the transformation matrix.

public XMatrix Transform { get; set; }

Property Value

XMatrix

PageNumber

Gets or sets the page number in the external PDF document this object refers to. The page number is one-based, i.e. it is in the range from 1 to PageCount. The default value is 1.

public int PageNumber { get; set; }

Property Value

Int32

PageIndex

Gets or sets the page index in the external PDF document this object refers to. The page index is zero-based, i.e. it is in the range from 0 to PageCount - 1. The default value is 0.

public int PageIndex { get; set; }

Property Value

Int32

ViewBox

Gets the view box of the form.

public XRect ViewBox { get; }

Property Value

XRect

HorizontalResolution

Gets 72, the horizontal resolution by design of a form object.

public double HorizontalResolution { get; }

Property Value

Double

VerticalResolution

Gets 72 always, the vertical resolution by design of a form object.

public double VerticalResolution { get; }

Property Value

Double

BoundingBox

Gets or sets the bounding box.

public XRect BoundingBox { get; set; }

Property Value

XRect

Interpolate

Gets or sets a flag indicating whether image interpolation is to be performed.

public bool Interpolate { get; set; }

Property Value

Boolean

Format

Gets the format of the image.

public XImageFormat Format { get; }

Property Value

XImageFormat

Methods

FromFile(String)

Creates an XPdfForm from a file.

public static XPdfForm FromFile(string path)

Parameters

path String

Returns

XPdfForm

FromStream(Stream)

Creates an XPdfForm from a stream.

public static XPdfForm FromStream(Stream stream)

Parameters

stream Stream

Returns

XPdfForm

Finish()

Sets the form in the state FormState.Finished.

internal void Finish()

Dispose(Boolean)

Frees the memory occupied by the underlying imported PDF document, even if other XPdfForm objects refer to this document. A reuse of this object doesn’t fail, because the underlying PDF document is re-imported if necessary.

protected void Dispose(bool disposing)

Parameters

disposing Boolean

ExtractPageNumber(String, Int32&)

Extracts the page number if the path has the form ‘MyFile.pdf#123’ and returns the actual path without the number sign and the following digits.

public static string ExtractPageNumber(string path, Int32& pageNumber)

Parameters

path String

pageNumber Int32&

Returns

String