class HexaPDF::Type::Annotations::Widget

Parent

Widget annotations are used by interactive forms to represent the appearance of fields and to manage user interactions.

See: PDF2.0 s12.5.6.19, HexaPDF::Type::Annotation

Field Definitions

NameType/Allowed ValuesRequiredDefault Value
TypeSymbolfalse:Annot
SubtypeSymboltruenil
RectHexaPDF::Rectangle or Arraytruenil
ContentsStringfalsenil
PHexaPDF::Dictionary or Hashfalsenil
NMStringfalsenil
MHexaPDF::DictionaryFields::PDFDate or String or Time or Date or DateTimefalsenil
FIntegerfalse0
APHexaPDF::Type::Annotation::AppearanceDictionary or Hashfalsenil
ASSymbolfalsenil
BorderHexaPDF::PDFArray or Arrayfalse[0, 0, 1]
CHexaPDF::PDFArray or Arrayfalsenil
StructParentIntegerfalsenil
OCHexaPDF::Dictionary or Hashfalsenil
SubtypeSymboltrue:Widget
HSymbol
One of: :N, :I, :O, :P, :T
falsenil
MKHexaPDF::Type::Annotations::Widget::AppearanceCharacteristics or Hashfalsenil
AHexaPDF::Dictionary or Hashfalsenil
AAHexaPDF::Dictionary or Hashfalsenil
BSHexaPDF::Type::Annotation::Border or Hashfalsenil
ParentHexaPDF::Dictionary or Hashfalsenil

Constants

BorderStyle

Describes the border of an annotation.

The color property is either nil if the border is transparent or else a device color object - see HexaPDF::Content::ColorSpace.

The style property can be one of the following:

:solid

Solid line.

:beveled

Embossed rectangle seemingly raised above the surface of the page.

:inset

Engraved rectangle receeding into the page.

:underlined

Underlined, i.e. only the bottom border is draw.

Array: Dash array describing how to dash the line.

Public Instance Methods

background_color → background_color or nil
background_color(*color) → widget

Returns the current background color as device color object, or nil if no background color is set, when no argument is given. Otherwise sets the background color using the color argument and returns self.

See HexaPDF::Content::ColorSpace.device_color_from_specification for information on the allowed arguments.

border_style → border_style
border_style(color: 0, width: 1, style: :solid) → widget

Returns a BorderStyle instance representing the border style of the widget when no argument is given. Otherwise sets the border style of the widget and returns self.

When setting a border style, arguments that are not provided will use the default: a border with a solid, black, 1pt wide line. This also means that multiple invocations will reset all prior values.

color

The color of the border. See HexaPDF::Content::ColorSpace.device_color_from_specification for information on the allowed arguments.

If the special value :transparent is used when setting the color, a transparent is used. A transparent border will return a nil value when getting the border color.

width

The width of the border. If set to 0, no border is shown.

style

Defines how the border is drawn. can be one of the following:

:solid

Draws a solid border.

:beveled

Draws a beveled border.

:inset

Draws an inset border.

:underlined

Draws only the bottom border.

Array

An array specifying a line dash pattern (see HexaPDF::Content::LineDashPattern)

form_field()

Returs the AcroForm field object to which this widget annotation belongs.

Since a widget and a field can share the same dictionary object, the returned object is often just the widget re-wrapped in the correct field class.

marker_style → marker_style
marker_style(style: nil, size: nil, color: nil) → widget

Returns a MarkerStyle instance representing the marker style of the widget when no argument is given. Otherwise sets the button marker style of the widget and returns self.

This method returns valid information only for check boxes and radio buttons!

When setting a marker style, arguments that are not provided will use the default: a black auto-sized checkmark (i.e. :check for for check boxes) or circle (:circle for radio buttons). This also means that multiple invocations will reset all prior values.

Note: The marker is called “normal caption” in the PDF 1.7 spec and the /CA entry of the associated appearance characteristics dictionary. The marker size and color are set using the /DA key on the widget (although /DA is not defined for widget, this is how Acrobat does it).

See: PDF2.0 s12.5.6.19 and s12.7.4.3