pdf-forms 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b38b51cb4c9b3164c52041260accc25b36cb1bdb
4
- data.tar.gz: 590aeedcdc7d0481d6102b5d82468a46c80912c5
3
+ metadata.gz: d0cba3a0ac8871160ec4debf8ebb41c22402685c
4
+ data.tar.gz: 01df74572ed005083a33a5d8d8ab815db1d8a522
5
5
  SHA512:
6
- metadata.gz: ca665b990d61e8a9f7510d6b6580620ececf6b4d4ad2994a095be3dc719a92a2356a9314501dcab392ee0c0aab951239d2585048a94257a669cd5a9db4f51d07
7
- data.tar.gz: 5bcb0c643f3f8d20acea518730ba7a69977284a14910fc40006c9d026f0d7f99be500ed89dd91bfb279184b39e6cebc4cd1f9a1280ea1c16faefda03212c5f79
6
+ metadata.gz: 1dbb857efa9d1e37d9b060b6a811812cabcc687be51ba8a53726455d1a1af75a2b135d7ccae5586b22dd6ee96b6ad05cfe6f33279514a73a0e9af9d3effdbd70
7
+ data.tar.gz: 33b13326e82a0f7089de22171da9aaa1a30e90126b547921e0e04a85843281af5f049baca0f650dfefa6d9be244f3fcc2fea75eab94d69d7bfb500110a0ff9dd
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2009-2011 Jens Kraemer
3
+ Copyright (c) 2009-2014 Jens Kraemer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -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(tmp.path)
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 add_options(pwd)
85
- return if options.empty?
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 options[:flatten]
91
+ if option_or_global(:flatten, local_options)
88
92
  opt_args << 'flatten'
89
93
  end
90
- if options[:encrypt]
91
- opt_args.concat ['encrypt_128bit', 'owner_pw', pwd, options[:encrypt_options]]
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
@@ -1,5 +1,5 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  module PdfForms
4
- VERSION = '0.5.6'
4
+ VERSION = '0.5.7'
5
5
  end
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.6
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-02-28 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Fill out PDF forms with pdftk (http://www.accesspdf.com/pdftk/).
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: []