GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfForm Class

    Namespace:
    GemBox.Pdf.Content
    Assembly:
    GemBox.Pdf.dll

    A form XObject is a PDF content stream that is a self-contained description of any sequence of graphics objects (including path objects, text objects, and sampled images).

    A form XObject may be painted multiple times—either on several pages or at several locations on the same page—and produces the same results each time, subject only to the graphics state at the time it is invoked.

    • C#
    • VB.NET
    public sealed class PdfForm : PdfExternalObject
    Public NotInheritable Class PdfForm
        Inherits PdfExternalObject
    Inheritance:
    Object
    PdfObject
    PdfContentResource
    PdfExternalObject
    PdfForm

    Constructors

    PdfForm(PdfDocument, PdfSize)

    Initializes a new instance of the PdfForm class.

    • C#
    • VB.NET
    public PdfForm(PdfDocument document, PdfSize size)
    Public Sub New(document As PdfDocument, size As PdfSize)
    Parameters
    document
    PdfDocument

    The PdfDocument associated with the PdfForm.

    size
    PdfSize

    The size of the PdfForm.

    Exceptions
    ArgumentNullException

    document is null.

    Properties

    BoundingBox

    (Required) The form XObject's bounding box, used to clip the form XObject and to determine its size for caching.

    • C#
    • VB.NET
    public PdfRectangle BoundingBox { get; set; }
    Public Property BoundingBox As PdfRectangle
    Property Value
    PdfRectangle

    The form XObject's bounding box, used to clip the form XObject and to determine its size for caching.

    Exceptions
    ArgumentNullException

    Value is null.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.10.2 Form Dictionaries'

    Content

    Gets the content of the PdfForm.

    Returns null if the PdfForm doesn't have an associated resource dictionary. In that case use either GetContent(PdfContent) to retrieve the read-only content of the PdfForm with PdfContentResources (fonts, images, etc.) resolved from the specified PdfContent or SetResources(PdfContent) method to set PdfContentResources (fonts, images, etc.) from the specified PdfContent to this PdfForm before retrieving the Content property.

    • C#
    • VB.NET
    public PdfContent Content { get; }
    Public ReadOnly Property Content As PdfContent
    Property Value
    PdfContent

    Gets a value of type PdfContent that represents the collection of PdfContentElements in the PdfForm.

    Remarks

    A PdfForm stores its rendering data in a content stream (whose data consists of a sequence of instructions describing the graphical elements to be painted) and an associated resource dictionary. For more information on how PdfForms store graphics data, see 7.8, "Content Streams and Resources".

    See Also
    PDF Specification ISO 32000-1:2008, section '8.10 Form XObjects'

    Size

    Gets the form size in the original (untransformed) coordinate system in which Transform is Identity.

    • C#
    • VB.NET
    public PdfSize Size { get; }
    Public ReadOnly Property Size As PdfSize
    Property Value
    PdfSize

    The form size in the original (untransformed) coordinate system in which Transform is Identity.

    Transform

    (Optional) An array of six numbers specifying the form matrix, which maps form space into user space (see 8.3.4, "Transformation Matrices"). Default value: the identity matrix [1 0 0 1 0 0].

    • C#
    • VB.NET
    public PdfMatrix Transform { get; set; }
    Public Property Transform As PdfMatrix
    Property Value
    PdfMatrix

    An array of six numbers specifying the form matrix, which maps form space into user space.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.10.2 Form Dictionaries'

    Methods

    GetContent(PdfContent)

    Gets the read-only content of the PdfForm with PdfContentResources (fonts, images, etc.) resolved from the specified resourcesProvider.

    To get the editable content of the PdfForm, use the Content property and, optionally, SetResources(PdfContent) method before it, if the Content property returns null.

    • C#
    • VB.NET
    public PdfContent GetContent(PdfContent resourcesProvider)
    Public Function GetContent(resourcesProvider As PdfContent) As PdfContent
    Parameters
    resourcesProvider
    PdfContent

    The PdfContent whose PdfContentResources (fonts, images, etc.) are used to resolve resources used by the PdfForm's content stream.

    Returns
    PdfContent

    The read-only content of the PdfForm with PdfContentResources (fonts, images, etc.) resolved from the specified resourcesProvider.

    SetBoundingBox(Double, Double, Double, Double)

    Sets the BoundingBox.

    • C#
    • VB.NET
    public void SetBoundingBox(double left, double bottom, double right, double top)
    Public Sub SetBoundingBox(left As Double, bottom As Double, right As Double, top As Double)
    Parameters
    left
    Double

    The left X coordinate of the BoundingBox.

    bottom
    Double

    The bottom Y coordinate of the BoundingBox.

    right
    Double

    The right X coordinate of the BoundingBox.

    top
    Double

    The top Y coordinate of the BoundingBox.

    SetResources(PdfContent)

    Sets the PdfContentResources (fonts, images, etc.) from the specified PdfContent to this PdfForm.

    This method is useful if the Content property returns null (if the PdfForm doesn't have an associated resource dictionary).

    • C#
    • VB.NET
    public void SetResources(PdfContent resourcesProvider)
    Public Sub SetResources(resourcesProvider As PdfContent)
    Parameters
    resourcesProvider
    PdfContent

    The PdfContent whose PdfContentResources (fonts, images, etc.) are set to this PdfForm.

    Inherited Properties

    AssociatedFiles

    (Optional; PDF 2.0) An array of one or more PdfFileSpecifications which denote the associated files for this PdfImage or PdfForm.

    (Inherited from PdfExternalObject)

    Document

    Gets the PdfDocument associated with this PdfContentResource or null if no PdfDocument is associated with this PdfContentResource.

    (Inherited from PdfContentResource)

    Metadata

    (Optional; PDF 1.4) A metadata stream containing metadata for the component.

    (Inherited from PdfObject)

    Extension Methods

    PdfObjectExtensions.GetDictionary(PdfObject)
    PdfObjectExtensions.GetOrAddDictionary(PdfObject)
    PdfObjectExtensions.GetArray(PdfObject)

    Examples

    Form XObjects example
    Content Streams and Resources example

    See Also

    PDF Specification ISO 32000-1:2008, section '8.10 Form XObjects'
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.