prawn-fillform 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/examples/main.rb +3 -3
- data/lib/prawn-fillform/version.rb +1 -1
- data/lib/prawn-fillform.rb +21 -17
- metadata +2 -2
data/README.md
CHANGED
@@ -16,9 +16,9 @@ require 'prawn-fillform'
|
|
16
16
|
|
17
17
|
data = {}
|
18
18
|
data[:page_1] = {}
|
19
|
-
data[:page_1][:firstname] = "Max"
|
20
|
-
data[:page_1][:lastname] = "Mustermann"
|
21
|
-
data[:page_1][:photo] = "test.jpg"
|
19
|
+
data[:page_1][:firstname] = { :value => "Max" }
|
20
|
+
data[:page_1][:lastname] = { :value => "Mustermann" }
|
21
|
+
data[:page_1][:photo] = { :value => "test.jpg" }
|
22
22
|
|
23
23
|
# Create a PDF file with predefined data Fields
|
24
24
|
Prawn::Document.generate "output.pdf", :template => "template.pdf" do |pdf|
|
data/examples/main.rb
CHANGED
@@ -9,9 +9,9 @@ require 'prawn/fillform'
|
|
9
9
|
|
10
10
|
data = {}
|
11
11
|
data[:page_1] = {}
|
12
|
-
data[:page_1][:firstname] = "Max"
|
13
|
-
data[:page_1][:lastname] = "Mustermann"
|
14
|
-
data[:page_1][:photo] = "../data/test.jpg"
|
12
|
+
data[:page_1][:firstname] = { :value => "Max" }
|
13
|
+
data[:page_1][:lastname] = { :value => "Mustermann" }
|
14
|
+
data[:page_1][:photo] = { :value => "../data/test.jpg" }
|
15
15
|
|
16
16
|
|
17
17
|
Prawn::Document.generate "../data/output.pdf", :template => "../data/template.pdf" do |pdf|
|
data/lib/prawn-fillform.rb
CHANGED
@@ -128,11 +128,13 @@ module Prawn
|
|
128
128
|
def collect!
|
129
129
|
@state.pages.each_with_index do |page, i|
|
130
130
|
annots = deref(page.dictionary.data[:Annots])
|
131
|
-
annots
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
if annots
|
132
|
+
annots.map do |ref|
|
133
|
+
reference = {}
|
134
|
+
reference[:ref] = ref
|
135
|
+
reference[:annots] = annots
|
136
|
+
@refs << reference
|
137
|
+
end
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
@@ -167,18 +169,20 @@ module Prawn
|
|
167
169
|
annots = deref(page.dictionary.data[:Annots])
|
168
170
|
page_number = "page_#{i+1}".to_sym
|
169
171
|
acroform[page_number] = []
|
170
|
-
annots
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
172
|
+
if annots
|
173
|
+
annots.map do |ref|
|
174
|
+
dictionary = deref(ref)
|
175
|
+
|
176
|
+
next unless deref(dictionary[:Type]) == :Annot and deref(dictionary[:Subtype]) == :Widget
|
177
|
+
next unless (deref(dictionary[:FT]) == :Tx || deref(dictionary[:FT]) == :Btn)
|
178
|
+
|
179
|
+
type = deref(dictionary[:FT]).to_sym
|
180
|
+
case type
|
181
|
+
when :Tx
|
182
|
+
acroform[page_number] << Text.new(dictionary)
|
183
|
+
when :Btn
|
184
|
+
acroform[page_number] << Button.new(dictionary)
|
185
|
+
end
|
182
186
|
end
|
183
187
|
end
|
184
188
|
end
|
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.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-07 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|