Class: Acrofill::Filler
- Inherits:
-
Object
- Object
- Acrofill::Filler
- Defined in:
- lib/acrofill/filler.rb
Overview
Instance Method Summary collapse
-
#apply(doc, destination, data, options) ⇒ Object
Shared fill pipeline, also driven by Template with a restored document.
-
#field_names(template) ⇒ Object
Fully-qualified names of all fillable fields.
-
#fields(template) ⇒ Object
Field metadata (name, type, current value, checkbox/radio states) without modifying the document.
- #fill_form(template, destination, data = {}, options = {}) ⇒ Object
-
#initialize ⇒ Filler
constructor
Accepts and ignores a pdftk path argument for drop-in compatibility.
Constructor Details
#initialize ⇒ Filler
Accepts and ignores a pdftk path argument for drop-in compatibility.
12 |
# File 'lib/acrofill/filler.rb', line 12 def initialize(*); end |
Instance Method Details
#apply(doc, destination, data, options) ⇒ Object
Shared fill pipeline, also driven by Template with a restored document. Values are normalized to valid UTF-8 up front so that a mis-encoded input degrades (replacement character) instead of leaking a raw Encoding error from deep inside the appearance code.
33 34 35 36 37 38 39 40 41 |
# File 'lib/acrofill/filler.rb', line 33 def apply(doc, destination, data, ) form = Form.new(doc) data.each do |name, value| form.fill(normalize(name), normalize(value)) end form.flatten! if [:flatten] || ['flatten'] File.binwrite(destination, Writer.new(doc).render) destination end |
#field_names(template) ⇒ Object
Fully-qualified names of all fillable fields.
25 26 27 |
# File 'lib/acrofill/filler.rb', line 25 def field_names(template) fields(template).map(&:name) end |