prawn-fillform 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/prawn-fillform/version.rb +1 -1
- data/lib/prawn-fillform.rb +18 -8
- metadata +1 -1
data/lib/prawn-fillform.rb
CHANGED
@@ -116,18 +116,25 @@ module Prawn
|
|
116
116
|
|
117
117
|
def delete!
|
118
118
|
@refs.each do |ref|
|
119
|
-
ref[:
|
119
|
+
ref[:acroform_fields].delete(ref[:field])
|
120
|
+
deref(deref(ref[:page])[:Annots]).delete(ref[:field])
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
123
124
|
protected
|
124
125
|
def collect!
|
126
|
+
|
127
|
+
root = deref(@state.store.root)
|
128
|
+
acro_form = deref(root[:AcroForm])
|
129
|
+
form_fields = deref(acro_form[:Fields])
|
130
|
+
|
125
131
|
@state.pages.each_with_index do |page, i|
|
126
|
-
|
127
|
-
|
132
|
+
form_fields.map do |ref|
|
133
|
+
field_dict = deref(ref)
|
128
134
|
reference = {}
|
129
|
-
reference[:
|
130
|
-
reference[:
|
135
|
+
reference[:page] = field_dict[:P]
|
136
|
+
reference[:field] = ref
|
137
|
+
reference[:acroform_fields] = form_fields
|
131
138
|
@refs << reference
|
132
139
|
end
|
133
140
|
end
|
@@ -146,12 +153,15 @@ module Prawn
|
|
146
153
|
|
147
154
|
def acroform_fields
|
148
155
|
acroform = {}
|
156
|
+
|
157
|
+
root = deref(state.store.root)
|
158
|
+
acro_form = deref(root[:AcroForm])
|
159
|
+
form_fields = deref(acro_form[:Fields])
|
160
|
+
|
149
161
|
state.pages.each_with_index do |page, i|
|
150
|
-
annots = deref(page.dictionary.data[:Annots])
|
151
162
|
page_number = "page_#{i+1}".to_sym
|
152
163
|
acroform[page_number] = []
|
153
|
-
|
154
|
-
annots.map do |ref|
|
164
|
+
form_fields.map do |ref|
|
155
165
|
dictionary = deref(ref)
|
156
166
|
|
157
167
|
next unless deref(dictionary[:Type]) == :Annot and deref(dictionary[:Subtype]) == :Widget
|