Method: HexaPDF::Type::AcroForm::TextField#create_appearances

Defined in:
lib/hexapdf/type/acro_form/text_field.rb

#create_appearances(force: false) ⇒ Object

Creates appropriate appearances for all widgets.

For information on how this is done see AppearanceGenerator.

Note that no new appearances are created if the field value hasn’t changed between invocations.

By setting force to true the creation of the appearances can be forced.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/hexapdf/type/acro_form/text_field.rb', line 226

def create_appearances(force: false)
  current_value = field_value
  appearance_generator_class = document.config.constantize('acro_form.appearance_generator')
  each_widget do |widget|
    is_cached = widget.cached?(:last_value)
    unless force
      if is_cached && widget.cache(:last_value) == current_value
        next
      elsif !is_cached && widget.appearance?
        widget.cache(:last_value, current_value, update: true)
        next
      end
    end
    widget.cache(:last_value, current_value, update: true)
    appearance_generator_class.new(widget).create_text_appearances
  end
end