pdf-forms 1.4.0 → 1.5.1

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
  SHA256:
3
- metadata.gz: 6f7ed295a6b7127c97a398655de313fcce3950b3ea32b62b31ecafb72993315e
4
- data.tar.gz: 432d25045b4cc7383aa2500cc66da6f7ca058be803965be1fab3dd202be1eff8
3
+ metadata.gz: 822913ae5ddafd1351543d61153398662cbe52506d5b766f2bd385075c105aba
4
+ data.tar.gz: 9795775687461877705fd8168381bf02b02bb89324cd54e8f4b5735a4cb0b5ef
5
5
  SHA512:
6
- metadata.gz: 439a63e18b1ee43256ca559f6fcd7a34faa9ac2db6ccb807ec91c2378c16bc5db840bb772d6ba59690cd856cb82e98bc814cdade458800dcb6744c3ace4aaaee
7
- data.tar.gz: e6e7e593801b25ad4912e8d3eaf647d27f6ca1aad08ca8a170cee702c9d5781a3353f3fcc7af56f9f94c28a8bcb9b98c6320d9452f05e3c5fea17d86bbd51904
6
+ metadata.gz: 305bc7b8ef657981e25b34dc67ff7565b7d3536b1b9e5fc5a2c7e2d0ec27371648370ef8bfe79d586a311aa0cdd9d438180b2a4336a4fc7274be4a339cbd9f19
7
+ data.tar.gz: c2d08fae7eb158ed9229cdae6443cae0c0ff37f491424e901f89108ddce49473881770fb55c507a464b8436bed1615cc7ee69a0fca9321bfb000c9fbcbd8cd1f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # pdf-forms [![Build Status](https://travis-ci.org/jkraemer/pdf-forms.png?branch=master)](https://travis-ci.org/jkraemer/pdf-forms)
1
+ # pdf-forms ![Build Status](https://github.com/jkraemer/pdf-forms/actions/workflows/run_tests.yml/badge.svg)
2
2
 
3
3
  http://github.com/jkraemer/pdf-forms/
4
4
 
@@ -89,6 +89,9 @@ pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {foo: 'bar'}, encrypt: true,
89
89
 
90
90
  # you can also protect the PDF even from opening by specifying an additional user_pw option:
91
91
  pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {foo: 'bar'}, encrypt: true, encrypt_options: 'user_pw secret'
92
+
93
+ # if you are facing font issues with your pdf, you can specify :replacement_font option:
94
+ pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {foo: 'bar'}, replacement_font: '/path/to/font'
92
95
  ```
93
96
 
94
97
  Any options shown above can also be set when initializing the PdfForms
@@ -103,7 +106,8 @@ In case your form's field names contain HTML entities (like
103
106
 
104
107
  ### Non-ASCII Characters (UTF8 etc) are not displayed in the filled out PDF
105
108
 
106
- First, check if the field value has been stored properly in the output PDF using `pdftk output.pdf dump_data_fields_utf8`.
109
+ First, try to use the `replacement_font` option and specify the font that's not being displayed.
110
+ If it doesn't work, check if the field value has been stored properly in the output PDF using `pdftk output.pdf dump_data_fields_utf8`.
107
111
 
108
112
  If it has been stored but is not rendered, your input PDF lacks the proper font for your kind of characters. Re-create it and embed any necessary fonts.
109
113
  If the value has not been stored, there is a problem with filling out the form, either on your side, of with this gem.
@@ -84,8 +84,20 @@ module PdfForms
84
84
 
85
85
  # returns the commands output, check general execution success with
86
86
  # $?.success?
87
+ #
88
+ # The method will throw a PdftkError if pdftk returns with a non-zero exit
89
+ # code *and* the output contains the word "Error" (case insensitive).
90
+ #
91
+ # This is to satisfy both the requirements of not failing silently in case of
92
+ # PDFtk errors (https://github.com/jkraemer/pdf-forms/issues/80) as well as
93
+ # tolerating non-zero exit codes that are merely warnings
94
+ # (https://github.com/jkraemer/pdf-forms/issues/86)
87
95
  def call_pdftk(*args)
88
- SafeShell.execute! pdftk, *(args.flatten)
96
+ output = SafeShell.execute pdftk, *(args.flatten)
97
+ if !$?.success? and output.to_s =~ /Error/i
98
+ raise PdftkError.new("pdftk failed with command\n#{pdftk} #{args.flatten.compact.join ' '}\ncommand output was:\n#{output}")
99
+ end
100
+ return output
89
101
  end
90
102
 
91
103
  # concatenate documents, can optionally specify page ranges
@@ -158,6 +170,9 @@ module PdfForms
158
170
  encrypt_options = encrypt_options.split if String === encrypt_options
159
171
  args << ['encrypt_128bit', 'owner_pw', encrypt_pass, encrypt_options]
160
172
  end
173
+ if option_or_global(:replacement_font, local_options)
174
+ args << ['replacement_font', option_or_global(:replacement_font, local_options)]
175
+ end
161
176
  args.flatten!
162
177
  args.compact!
163
178
  args
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  module PdfForms
4
- VERSION = '1.4.0'
2
+ VERSION = '1.5.1'
5
3
  end
@@ -19,15 +19,19 @@ module PdfForms
19
19
  REXML::Text.new(value.to_s).to_s
20
20
  end
21
21
 
22
+ def escape(value)
23
+ Array(value).map{ |v| quote(v) }.join(" ")
24
+ end
25
+
22
26
  def header
23
27
  '<?xml version="1.0" encoding="UTF-8"?>
24
28
  <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
25
29
  <fields>
26
30
  '
27
31
  end
28
-
32
+
29
33
  def field(key, value)
30
- "<field name=\"#{key}\"><value>#{Array(value).map{ |v| quote(v) }.join(" ")}</value></field>"
34
+ "<field name=\"#{escape(key)}\"><value>#{escape(value)}</value></field>"
31
35
  end
32
36
 
33
37
  def footer
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Krämer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2024-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cliver
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rexml
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 3.2.6
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.2'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 3.2.6
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.2'
47
67
  - !ruby/object:Gem::Dependency
48
68
  name: bundler
49
69
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +118,7 @@ homepage: http://github.com/jkraemer/pdf-forms
98
118
  licenses:
99
119
  - MIT
100
120
  metadata: {}
101
- post_install_message:
121
+ post_install_message:
102
122
  rdoc_options: []
103
123
  require_paths:
104
124
  - lib
@@ -113,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
133
  - !ruby/object:Gem::Version
114
134
  version: 1.3.6
115
135
  requirements: []
116
- rubygems_version: 3.0.3
117
- signing_key:
136
+ rubygems_version: 3.3.26
137
+ signing_key:
118
138
  specification_version: 4
119
139
  summary: Fill out PDF forms with pdftk (http://www.accesspdf.com/pdftk/).
120
140
  test_files: []