Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 82 lines (49 sloc) 2.094 kb
be312e7 add README.md
Maurice Hadamczyk authored
1 # Prawn/Fillform: Fill Text and Images through Acroform Fields
2
cb6d0ea @moessimple Update readme.md
authored
3 ### Sorry, I have unfortunately no time to maintain the code. You can use the code for any purpose.
9a8a5a1 Update README.md
moessimple authored
4
be312e7 add README.md
Maurice Hadamczyk authored
5 ## Install
6
7 ```bash
8 $ gem install prawn-fillform
9 ```
10
11 ## Usage
0b2a422 extended README
Maurice Hadamczyk authored
12 Create a PDF form with Scribus, Adobe Products or something else. I have only tested this with Scribus.
13 Currently only text fields and buttons are supported. Buttons are replaced by images.
14
be312e7 add README.md
Maurice Hadamczyk authored
15
16 ```ruby
17 require 'prawn-fillform'
18
19 data = {}
20 data[:page_1] = {}
42a7b2f update readme and example
Maurice Hadamczyk authored
21 data[:page_1][:firstname] = { :value => "Max" }
22 data[:page_1][:photo] = { :value => "test.jpg" }
be312e7 add README.md
Maurice Hadamczyk authored
23
c9b6c8b template.pdf fix in examples and requires active_support
Maurice Hadamczyk authored
24 # Page number optional, substitute lastname var in all pages, thanks to hoverlover
25 data[:lastname] = { :value => "Mustermann" }
26
be312e7 add README.md
Maurice Hadamczyk authored
27 # Create a PDF file with predefined data Fields
9daae0d README typo fix
Maurice Hadamczyk authored
28 Prawn::Document.generate "output.pdf", :template => "template.pdf" do |pdf|
be312e7 add README.md
Maurice Hadamczyk authored
29 pdf.fill_form_with(data)
30 end
1836b22 arrgh typo fix
Maurice Hadamczyk authored
31 ```
be312e7 add README.md
Maurice Hadamczyk authored
32
33 Take a look in `examples` folder
34
9307f91 Update README.md
moessimple authored
35 ## Thanks to netinlet for fix field placement bug
d50c1f2 @netinlet Added x_offset and y_offset capabilities at a Class and per fill_form_wi...
netinlet authored
36
c9b6c8b template.pdf fix in examples and requires active_support
Maurice Hadamczyk authored
37 I was having issue with the form field placement (see https://github.com/moessimple/prawn-fillform/issues/1)
d50c1f2 @netinlet Added x_offset and y_offset capabilities at a Class and per fill_form_wi...
netinlet authored
38 Scribus and Adobe Acrobat don't open pdf's in the same way so the formatting comes out differently. Much like
39 opening a Word document in OpenOffice can some render with funny formatting.
40
9307f91 Update README.md
moessimple authored
41 Added the ability to set :x_offset and :y_offset at the class level and on a per form basis.
d50c1f2 @netinlet Added x_offset and y_offset capabilities at a Class and per fill_form_wi...
netinlet authored
42
43 #Class Methods
44 ```ruby
45 Prawn::Document.set_fillform_xy_offset(x_offset, y_offset)
46
47 Prawn::Document.use_adobe_xy_offsets! # Your mileage may vary! Defaults to x_offset:2, y_offset:-40
48
49 Prawn::Document.fillform_x_offset
50
c9b6c8b template.pdf fix in examples and requires active_support
Maurice Hadamczyk authored
51 Prawn::Document.fillform_y_offset
d50c1f2 @netinlet Added x_offset and y_offset capabilities at a Class and per fill_form_wi...
netinlet authored
52 ```
53
54 #And on a per-form basis
55
56 See the :options param below
57
58 ```ruby
59 require 'prawn-fillform'
60
61 data = {}
62 data[:page_1] = {}
63 data[:page_1][:firstname] = { :value => "Max", :options => {:x_offset => 2, :y_offset => -40} }
64 data[:page_1][:lastname] = { :value => "Mustermann" }
65 data[:page_1][:photo] = { :value => "test.jpg" }
66
67 # Create a PDF file with predefined data Fields
68 Prawn::Document.generate "output.pdf", :template => "template.pdf" do |pdf|
69 pdf.fill_form_with(data)
70 end
71 ```
72
73
74
75
76
77
78
79
80
81
Something went wrong with that request. Please try again.