Class: Acrofill::Template
- Inherits:
-
Object
- Object
- Acrofill::Template
- Defined in:
- lib/acrofill/template.rb
Overview
A pre-parsed, reusable template. Parsing is the dominant cost of a fill (tokenizing and inflating the whole file); Template pays it once and restores a pristine object graph from a Marshal snapshot for each subsequent fill — roughly 50x faster than re-parsing per fill.
template = Acrofill::Template.new('claim_form.pdf')
template.fill_form('a.pdf', { 'Name' => 'Jane' }, flatten: true)
template.fill_form('b.pdf', { 'Name' => 'John' }, flatten: true)
Instances are cheap to keep around (the snapshot is a single string, comparable to the file size) and safe to share across threads: every fill works on its own restored copy.
Instance Method Summary collapse
- #field_names ⇒ Object
-
#fields ⇒ Object
Field metadata without touching disk again.
- #fill_form(destination, data = {}, options = {}) ⇒ Object
-
#initialize(path) ⇒ Template
constructor
A new instance of Template.
Constructor Details
Instance Method Details
#field_names ⇒ Object
31 32 33 |
# File 'lib/acrofill/template.rb', line 31 def field_names fields.map(&:name) end |