class HexaPDF::Type::Form

Parent

Represents a form XObject of a PDF document.

See: PDF2.0 s8.10

Field Definitions

NameType/Allowed ValuesRequiredDefault Value
LengthIntegerfalsenil
FilterSymbol or HexaPDF::PDFArray or Arrayfalsenil
DecodeParmsHexaPDF::Dictionary or HexaPDF::PDFArray or Hash or Arrayfalsenil
FHexaPDF::Type::FileSpecification or Hash or Stringfalsenil
FFilterSymbol or HexaPDF::PDFArray or Arrayfalsenil
FDecodeParmsHexaPDF::Dictionary or HexaPDF::PDFArray or Hash or Arrayfalsenil
DLIntegerfalsenil
TypeSymbolfalse:XObject
SubtypeSymboltrue:Form
FormTypeInteger
One of: 1
false1
BBoxHexaPDF::Rectangle or Arraytruenil
MatrixHexaPDF::PDFArray or Arrayfalse[1, 0, 0, 1, 0, 0]
ResourcesHexaPDF::Type::Resources or Hashfalsenil
GroupHexaPDF::Type::Form::Group or Hashfalsenil
RefHexaPDF::Type::Form::Reference or Hashfalsenil
MetadataHexaPDF::Stream or Hashfalsenil
PieceInfoHexaPDF::Dictionary or Hashfalsenil
LastModifiedHexaPDF::DictionaryFields::PDFDate or String or Time or Date or DateTimefalsenil
StructParentIntegerfalsenil
StructParentsIntegerfalsenil
OPIHexaPDF::Dictionary or Hashfalsenil
OCHexaPDF::Dictionary or Hashfalsenil
NameSymbolfalsenil
AFHexaPDF::PDFArray or Arrayfalsenil
MeasureHexaPDF::Dictionary or Hashfalsenil
PtDataHexaPDF::Dictionary or Hashfalsenil

Attributes

source_path[RW]

Returns the path to the PDF file that was used when creating the form object.

This value is only set when the form object was created by using the image loading facility (i.e. when treating a single page PDF file as image) and not when the form object was created in any other way (i.e. manually created or already part of a loaded PDF file).

Public Instance Methods

box()

Returns the rectangle defining the bounding box of the form.

canvas()

Returns the canvas for the form XObject.

The canvas object is cached once it is created so that its graphics state is correctly retained without the need for parsing its contents.

If the bounding box of the form XObject doesn’t have its origin at (0, 0), the canvas origin is translated into the bottom-left corner so that this detail doesn’t matter when using the canvas. This means that the canvas’ origin is always at the bottom-left corner of the bounding box.

Note that a canvas can only be retrieved for initially empty form XObjects!

contents()

Returns the contents of the form XObject.

Note: This is the same as stream but here for interface compatibility with Page.

contents=(data)

Replaces the contents of the form XObject with the given string.

This also clears the cache to avoid returning invalid objects.

Note: This is the same as stream= but here for interface compatibility with Page.

height()

Returns the height of the bounding box (see box).

process_contents(processor, original_resources: nil)

Processes the content stream of the form XObject with the given processor object.

The original_resources argument has to be set to a page’s resources if this form XObject is processed as part of this page.

See: HexaPDF::Content::Processor

reference_xobject?()

Returns true if the Form XObject is a reference XObject.

referenced_content()

Returns the referenced page as Form XObject, if this Form XObject is a Reference XObject and the referenced page is found. Otherwise returns nil.

resources()

Returns the resource dictionary which is automatically created if it doesn’t exist.

width()

Returns the width of the bounding box (see box).