prawn-fillform 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/README.md +47 -0
- data/lib/prawn-fillform.rb +24 -3
- data/lib/prawn-fillform/version.rb +1 -1
- data/prawn-fillform.gemspec +2 -0
- metadata +21 -4
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -28,3 +28,50 @@ end
|
|
28
28
|
|
29
29
|
Take a look in `examples` folder
|
30
30
|
|
31
|
+
## Per Fork netinlet/prawn-fillform
|
32
|
+
|
33
|
+
I was having issue with the form field placement (see https://github.com/moessimple/prawn-fillform/issues/1)
|
34
|
+
Scribus and Adobe Acrobat don't open pdf's in the same way so the formatting comes out differently. Much like
|
35
|
+
opening a Word document in OpenOffice can some render with funny formatting.
|
36
|
+
|
37
|
+
This fork added the ability to set :x_offset and :y_offset at the class level and on a per form basis.
|
38
|
+
|
39
|
+
#Class Methods
|
40
|
+
```ruby
|
41
|
+
Prawn::Document.set_fillform_xy_offset(x_offset, y_offset)
|
42
|
+
|
43
|
+
Prawn::Document.use_adobe_xy_offsets! # Your mileage may vary! Defaults to x_offset:2, y_offset:-40
|
44
|
+
|
45
|
+
Prawn::Document.fillform_x_offset
|
46
|
+
|
47
|
+
Prawn::Document.fillform_y_offset
|
48
|
+
```
|
49
|
+
|
50
|
+
#And on a per-form basis
|
51
|
+
|
52
|
+
See the :options param below
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
require 'prawn-fillform'
|
56
|
+
|
57
|
+
data = {}
|
58
|
+
data[:page_1] = {}
|
59
|
+
data[:page_1][:firstname] = { :value => "Max", :options => {:x_offset => 2, :y_offset => -40} }
|
60
|
+
data[:page_1][:lastname] = { :value => "Mustermann" }
|
61
|
+
data[:page_1][:photo] = { :value => "test.jpg" }
|
62
|
+
|
63
|
+
# Create a PDF file with predefined data Fields
|
64
|
+
Prawn::Document.generate "output.pdf", :template => "template.pdf" do |pdf|
|
65
|
+
pdf.fill_form_with(data)
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
data/lib/prawn-fillform.rb
CHANGED
@@ -6,7 +6,7 @@ OpenURI::Buffer::StringMax = 0
|
|
6
6
|
module Prawn
|
7
7
|
|
8
8
|
module Fillform
|
9
|
-
|
9
|
+
|
10
10
|
class Field
|
11
11
|
include Prawn::Document::Internals
|
12
12
|
|
@@ -152,6 +152,25 @@ module Prawn
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
155
|
+
|
156
|
+
module XYOffsets
|
157
|
+
def fillform_x_offset
|
158
|
+
@fillform_x_offset ||= 2
|
159
|
+
end
|
160
|
+
|
161
|
+
def fillform_y_offset
|
162
|
+
@fillform_y_offset ||= -1
|
163
|
+
end
|
164
|
+
|
165
|
+
def set_fillform_xy_offset(x_offset, y_offset)
|
166
|
+
@fillform_x_offset = x_offset
|
167
|
+
@fillform_y_offset = y_offset
|
168
|
+
end
|
169
|
+
|
170
|
+
def use_adobe_xy_offsets!
|
171
|
+
set_fillform_xy_offset(2, -40)
|
172
|
+
end
|
173
|
+
end
|
155
174
|
|
156
175
|
def acroform_field_names
|
157
176
|
result = []
|
@@ -190,7 +209,6 @@ module Prawn
|
|
190
209
|
end
|
191
210
|
|
192
211
|
def fill_form_with(data={})
|
193
|
-
|
194
212
|
acroform_fields.each do |page, fields|
|
195
213
|
fields.each do |field|
|
196
214
|
number = page.to_s.split("_").last.to_i
|
@@ -203,8 +221,10 @@ module Prawn
|
|
203
221
|
value = value.to_s
|
204
222
|
if field.type == :text
|
205
223
|
fill_color options[:font_color] || field.font_color
|
224
|
+
x_offset = options[:x_offset] || self.class.fillform_x_offset
|
225
|
+
y_offset = options[:y_offset] || self.class.fillform_y_offset
|
206
226
|
|
207
|
-
text_box value, :at => [field.x +
|
227
|
+
text_box value, :at => [field.x + x_offset, field.y + y_offset],
|
208
228
|
:align => options[:align] || field.align,
|
209
229
|
:width => options[:width] || field.width,
|
210
230
|
:height => options[:height] || field.height,
|
@@ -238,5 +258,6 @@ module Prawn
|
|
238
258
|
end
|
239
259
|
|
240
260
|
require 'prawn/document'
|
261
|
+
Prawn::Document.extend Prawn::Fillform::XYOffsets
|
241
262
|
Prawn::Document.send(:include, Prawn::Fillform)
|
242
263
|
|
data/prawn-fillform.gemspec
CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency "prawn"
|
19
21
|
|
20
22
|
# specify any dependencies here; for example:
|
21
23
|
# s.add_development_dependency "rspec"
|
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.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: prawn
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
description:
|
15
31
|
email:
|
16
32
|
- moessimple@googlemail.com
|
@@ -48,8 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
64
|
version: '0'
|
49
65
|
requirements: []
|
50
66
|
rubyforge_project: prawn-fillform
|
51
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.23
|
52
68
|
signing_key:
|
53
69
|
specification_version: 3
|
54
70
|
summary: fill text and images through acroform fields
|
55
71
|
test_files: []
|
72
|
+
has_rdoc:
|