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.
@@ -1,7 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Prawn
3
3
  module Fillform
4
- VERSION = "0.0.9"
4
+ VERSION = "0.0.10"
5
5
  end
6
6
  end
7
7
 
@@ -116,18 +116,25 @@ module Prawn
116
116
 
117
117
  def delete!
118
118
  @refs.each do |ref|
119
- ref[:annots].delete(ref[: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
- @annots = deref(page.dictionary.data[:Annots])
127
- @annots.map do |ref|
132
+ form_fields.map do |ref|
133
+ field_dict = deref(ref)
128
134
  reference = {}
129
- reference[:ref] = ref
130
- reference[:annots] = @annots
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
- acroform[page_number] = []
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-fillform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: