prawn-fillform 0.0.10 → 0.0.11

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.10"
4
+ VERSION = "0.0.11"
5
5
  end
6
6
  end
7
7
 
@@ -111,31 +111,41 @@ module Prawn
111
111
  def initialize(state)
112
112
  @state = state
113
113
  @refs = []
114
+ @refs_2 = []
114
115
  collect!
115
116
  end
116
117
 
117
118
  def delete!
118
119
  @refs.each do |ref|
120
+ ref[:annots].delete(ref[:ref])
121
+ end
122
+ @refs_2.each do |ref|
119
123
  ref[:acroform_fields].delete(ref[:field])
120
- deref(deref(ref[:page])[:Annots]).delete(ref[:field])
121
124
  end
122
125
  end
123
126
 
124
127
  protected
125
128
  def collect!
129
+ @state.pages.each_with_index do |page, i|
130
+ annots = deref(page.dictionary.data[:Annots])
131
+ annots.map do |ref|
132
+ reference = {}
133
+ reference[:ref] = ref
134
+ reference[:annots] = annots
135
+ @refs << reference
136
+ end
137
+ end
126
138
 
127
- root = deref(@state.store.root)
128
- acro_form = deref(root[:AcroForm])
129
- form_fields = deref(acro_form[:Fields])
139
+ root = deref(@state.store.root)
140
+ acro_form = deref(root[:AcroForm])
141
+ form_fields = deref(acro_form[:Fields])
130
142
 
131
143
  @state.pages.each_with_index do |page, i|
132
144
  form_fields.map do |ref|
133
- field_dict = deref(ref)
134
145
  reference = {}
135
- reference[:page] = field_dict[:P]
136
146
  reference[:field] = ref
137
147
  reference[:acroform_fields] = form_fields
138
- @refs << reference
148
+ @refs_2 << reference
139
149
  end
140
150
  end
141
151
  end
@@ -153,15 +163,11 @@ module Prawn
153
163
 
154
164
  def acroform_fields
155
165
  acroform = {}
156
-
157
- root = deref(state.store.root)
158
- acro_form = deref(root[:AcroForm])
159
- form_fields = deref(acro_form[:Fields])
160
-
161
166
  state.pages.each_with_index do |page, i|
167
+ annots = deref(page.dictionary.data[:Annots])
162
168
  page_number = "page_#{i+1}".to_sym
163
169
  acroform[page_number] = []
164
- form_fields.map do |ref|
170
+ annots.map do |ref|
165
171
  dictionary = deref(ref)
166
172
 
167
173
  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.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: