pdf-forms 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.rdoc +4 -2
- data/lib/pdf_forms/pdftk_wrapper.rb +13 -7
- data/lib/pdf_forms/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0cba3a0ac8871160ec4debf8ebb41c22402685c
|
4
|
+
data.tar.gz: 01df74572ed005083a33a5d8d8ab815db1d8a522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dbb857efa9d1e37d9b060b6a811812cabcc687be51ba8a53726455d1a1af75a2b135d7ccae5586b22dd6ee96b6ad05cfe6f33279514a73a0e9af9d3effdbd70
|
7
|
+
data.tar.gz: 33b13326e82a0f7089de22171da9aaa1a30e90126b547921e0e04a85843281af5f049baca0f650dfefa6d9be244f3fcc2fea75eab94d69d7bfb500110a0ff9dd
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -29,14 +29,16 @@ First get pdftk from http://www.accesspdf.com/pdftk/ and install it.
|
|
29
29
|
# add :data_format => 'XFdf' option to generate XFDF instead of FDF when filling a form
|
30
30
|
pdftk = PdfForms.new('/usr/local/bin/pdftk')
|
31
31
|
|
32
|
-
add :data_format => 'XFdf' option to generate XFDF instead of FDF when filling a form
|
33
|
-
|
34
32
|
# find out the field names that are present in form.pdf
|
35
33
|
pdftk.get_field_names 'path/to/form.pdf'
|
36
34
|
|
37
35
|
# take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
|
38
36
|
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', :foo => 'bar'
|
39
37
|
|
38
|
+
# optionally, add the :flatten option to prevent editing of a filled out form
|
39
|
+
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {:foo => 'bar'}, :flatten => true
|
40
|
+
|
41
|
+
|
40
42
|
|
41
43
|
|
42
44
|
== INSTALL:
|
@@ -20,14 +20,14 @@ module PdfForms
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# pdftk.fill_form '/path/to/form.pdf', '/path/to/destination.pdf', :field1 => 'value 1'
|
23
|
-
def fill_form(template, destination, data = {})
|
23
|
+
def fill_form(template, destination, data = {}, fill_options = {})
|
24
24
|
q_template = safe_path(template)
|
25
25
|
q_destination = safe_path(destination)
|
26
26
|
fdf = data_format(data)
|
27
27
|
tmp = Tempfile.new('pdf_forms-fdf')
|
28
28
|
tmp.close
|
29
29
|
fdf.save_to tmp.path
|
30
|
-
command = pdftk_command q_template, 'fill_form', safe_path(tmp.path), 'output', q_destination, add_options(
|
30
|
+
command = pdftk_command q_template, 'fill_form', safe_path(tmp.path), 'output', q_destination, add_options(fill_options)
|
31
31
|
output = %x{#{command}}
|
32
32
|
unless File.readable?(destination) && File.size(destination) > 0
|
33
33
|
fdf_path = nil
|
@@ -81,14 +81,20 @@ module PdfForms
|
|
81
81
|
quote_path(pdftk) + " #{args.flatten.compact.join ' '} 2>&1"
|
82
82
|
end
|
83
83
|
|
84
|
-
def
|
85
|
-
|
84
|
+
def option_or_global(attrib, local = {})
|
85
|
+
local[attrib] || options[attrib]
|
86
|
+
end
|
87
|
+
|
88
|
+
def add_options(local_options = {})
|
89
|
+
return if options.empty? && local_options.empty?
|
86
90
|
opt_args = []
|
87
|
-
if
|
91
|
+
if option_or_global(:flatten, local_options)
|
88
92
|
opt_args << 'flatten'
|
89
93
|
end
|
90
|
-
if
|
91
|
-
|
94
|
+
if option_or_global(:encrypt, local_options)
|
95
|
+
encrypt_pass = option_or_global(:encrypt_password, local_options)
|
96
|
+
encrypt_options = option_or_global(:encrypt_options, local_options)
|
97
|
+
opt_args.concat ['encrypt_128bit', 'owner_pw', encrypt_pass, encrypt_options]
|
92
98
|
end
|
93
99
|
opt_args
|
94
100
|
end
|
data/lib/pdf_forms/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf-forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Krämer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: A Ruby frontend to the pdftk binary, including FDF and XFDF creation.
|
14
|
+
Just pass your template and a hash of data to fill in.
|
14
15
|
email:
|
15
16
|
- jk@jkraemer.net
|
16
17
|
executables: []
|
@@ -30,7 +31,8 @@ files:
|
|
30
31
|
- LICENSE
|
31
32
|
- README.rdoc
|
32
33
|
homepage: http://github.com/jkraemer/pdf-forms
|
33
|
-
licenses:
|
34
|
+
licenses:
|
35
|
+
- MIT
|
34
36
|
metadata: {}
|
35
37
|
post_install_message:
|
36
38
|
rdoc_options: []
|