class HexaPDF::Type::AcroForm::VariableTextField

Parent

An AcroForm variable text field defines how text that it is not known at generation time should be rendered. For example, AcroForm text fields (normally) don’t have an initial value; the value is entered by the user and needs to be rendered correctly by the PDF reader.

See: PDF2.0 s12.7.4.3

Field Definitions

NameType/Allowed ValuesRequiredDefault Value
FTSymbol
One of: :Btn, :Tx, :Ch, :Sig
falsenil
ParentHexaPDF::Type::AcroForm::Field or Hashfalsenil
KidsHexaPDF::PDFArray or Arrayfalsenil
TStringfalsenil
TUStringfalsenil
TMStringfalsenil
FfIntegerfalse0
VHexaPDF::Dictionary or Symbol or String or HexaPDF::Stream or HexaPDF::PDFArray or Hash or Arrayfalsenil
DVHexaPDF::Dictionary or Symbol or String or HexaPDF::Stream or HexaPDF::PDFArray or Hash or Arrayfalsenil
AAHexaPDF::Dictionary or Hashfalsenil
DAStringfalsenil
QInteger
One of: 0, 1, 2
false0
DSStringfalsenil
RVString or HexaPDF::Stream or Hashfalsenil

Constants

INHERITABLE_FIELDS

All inheritable dictionary fields for text fields.

Public Class Methods

create_appearance_string(document, font: 'Helvetica', font_options: {}, font_size: 0, font_color: 0)

Creates an AcroForm appearance string for the HexaPDF document from the given arguments and returns it.

font

The name of the font.

font_options

Additional font options like :variant used when loading the font. See HexaPDF::Document::Fonts#add

font_size

The font size. If this is set to 0, the font size is calculated using the height/width of the field.

font_color

The font color. See HexaPDF::Content::ColorSpace.device_color_from_specification for allowed values.

parse_appearance_string(string) → [font_name, font_size, font_color]
parse_appearance_string(string) {|obj, params| block } → nil

Parses the given appearance string.

If no block is given, the appearance string is searched for font name, font size and font color all of which are returned. Otherwise the block is called with each found content stream operator and has to handle them itself.

Public Instance Methods

parse_default_appearance_string(widget = self)

Parses the default appearance string and returns an array containing [font_name, font_size, font_color].

The default appearance string is taken from the given widget of the field, falls back to the field itself or, if still not available, the default appearance string of the form.

The reason why a specific widget of the field can be specified is because the widgets of a field might differ in their visual representation.

set_default_appearance_string(font: 'Helvetica', font_options: {}, font_size: 0, font_color: 0)

Sets the default appearance string using the provided values or the default values which provide a sane default.

See ::create_appearance_string for information on the arguments.

text_alignment → alignment
text_alignment(alignment) → field

Sets or returns the text alignment that should be used when displaying text.

With no argument, the current text alignment is returned. When a value is provided, the text alignment is set accordingly.

The alignment value is one of :left, :center or :right.