Class: Pdfrb::Model::Type::VariableTextField

Inherits:
Field show all
Defined in:
lib/pdfrb/model/type/variable_text_field.rb

Overview

Variable Text Field (s12.7.4.3). Base for text fields with dynamic appearance generation. Adds /DA, /Q, /RV.

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Field

#additional_actions, #alternate_field_name, #appearance_characteristics, #button?, #choice?, #default_value, #field_name, #field_type, #field_value, #flags, #fully_qualified_name, #has_kids?, #kids, #mapping_field_name, #no_export?, #parent, #read_only?, #required?, #resolved_parent, #root_field, #signature?, #terminal_field?, #text?

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Instance Method Details

#daObject



10
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 10

def da; self[:DA]; end

#default_appearanceObject



9
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 9

def default_appearance; self[:DA]; end

#default_appearance_colorObject



36
37
38
39
40
41
42
43
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 36

def default_appearance_color
  return nil unless default_appearance

  match = default_appearance.to_s.match(/([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+rg/)
  return nil unless match

  [match[1].to_f, match[2].to_f, match[3].to_f]
end

#default_appearance_fontObject



27
28
29
30
31
32
33
34
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 27

def default_appearance_font
  return nil unless default_appearance

  match = default_appearance.to_s.match(/\/(\w+)\s+([\d.]+)\s+Tf/)
  return nil unless match

  [match[1].to_sym, match[2].to_f]
end

#has_rich_text?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 23

def has_rich_text?
  !!rv
end

#qObject



11
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 11

def q; self[:Q]; end

#rvObject



12
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 12

def rv; self[:RV]; end

#text_alignmentObject



14
15
16
17
18
19
20
21
# File 'lib/pdfrb/model/type/variable_text_field.rb', line 14

def text_alignment
  case q
  when 1 then :center
  when 2 then :right
  when 3 then :justify
  else :left
  end
end