pdf-forms 1.2.0 → 1.3.0

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: 72a9789f0cd4a13555123fd0d5736cb0bb2fe8a671a501994c0880bc0f26bb05
4
- data.tar.gz: cb6472a02f6779107051cdb44619ca04fced3b011b6c3fdaa5625d9274ce41c1
3
+ metadata.gz: 40651e7dd3bdc30c69263f76ecc3883c8be80f985e431509ee51e9d51bc0aa8d
4
+ data.tar.gz: 7e0ab952ddd42be27d4a58de7acdda3d7ef54d1588e889432ec3be922ac1b722
5
5
  SHA512:
6
- metadata.gz: 7ab804f59b1953b84e9862bc0879dbaac34b233b85f81a64d64708c9d5a9839ac2186b48e258f908b48524f2cd28294b02b058d29be0a740ac51b9b9286d5848
7
- data.tar.gz: f806a512d4a570ee1ff7bc3da5d7f6b81a95b98472784513b120e3099840fbe14f8c7bd61812efdf1ef804f43e32ca7426e3e7c4aa91bb30230151bf7a67406f
6
+ metadata.gz: d12c30fbdeabb1443f33d6f52af39e442241ce44158f9095ca909d3de434caef47df83156ba05ae08169d6bed5840220fb8d80dda673c441c3e414fd64ca3a8e
7
+ data.tar.gz: 9a7c21dc930ffe1249258f730cd628bf77a115fd64f84fef5df994fdef5e88e3be227d09e0cdcb862550a8ede7f25afb7fdb73083297f9c0958e998b748f5b6b
data/README.md CHANGED
@@ -15,6 +15,31 @@ http://www.pdflabs.com/tools/pdftk-server/ and install it, or run
15
15
  After that, add `pdf-forms` to your Gemfile or manually install the gem. Nothing
16
16
  unusual here.
17
17
 
18
+ ### Using the Java port of PDFTK
19
+
20
+ The PDFTK package was dropped from most (all?) current versions of major Linux distributions.
21
+ As contributed in [this issue](https://github.com/jkraemer/pdf-forms/issues/75#issuecomment-698436643), you can use the [Java version of PDFTK](https://gitlab.com/pdftk-java/pdftk)
22
+ with this gem, as well. Just create a small shell script:
23
+
24
+ ~~~shell
25
+ #!/bin/sh
26
+ MYSELF=`which "$0" 2>/dev/null`
27
+ [ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
28
+ java=java
29
+ if test -n "$JAVA_HOME"; then
30
+ java="$JAVA_HOME/bin/java"
31
+ fi
32
+ exec "$java" $java_args -jar $MYSELF "$@"
33
+ exit 1
34
+ ~~~
35
+
36
+ Next, concatenate the wrapper script and the Jar file, and you end up with an executable that
37
+ can be used with pdf-forms:
38
+
39
+ ~~~
40
+ cat stub.sh pdftk-all.jar > pdftk.run && chmod +x pdftk.run
41
+ ~~~
42
+
18
43
 
19
44
  ## Usage
20
45
 
@@ -54,7 +79,8 @@ pdftk.get_field_names 'path/to/form.pdf'
54
79
  # take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
55
80
  pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', :foo => 'bar'
56
81
 
57
- # optionally, add the :flatten option to prevent editing of a filled out form
82
+ # optionally, add the :flatten option to prevent editing of a filled out form.
83
+ # Other supported options are :drop_xfa and :drop_xmp.
58
84
  pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {:foo => 'bar'}, :flatten => true
59
85
 
60
86
  # to enable PDF encryption, pass encrypt: true. By default, a random 'owner
@@ -75,6 +101,14 @@ In case your form's field names contain HTML entities (like
75
101
  `Straße Hausnummer`), make sure you unescape those before using them, i.e.
76
102
  `CGI.unescapeHTML(name)`. Thanks to @phoet for figuring this out in #65.
77
103
 
104
+ ### Non-ASCII Characters (UTF8 etc) are not displayed in the filled out PDF
105
+
106
+ First, check if the field value has been stored properly in the output PDF using `pdftk output.pdf dump_data_fields_utf8`.
107
+
108
+ 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
+ If the value has not been stored, there is a problem with filling out the form, either on your side, of with this gem.
110
+
111
+ Also see [UTF-8 chars are not displayed in the filled PDF](https://github.com/jkraemer/pdf-forms/issues/53)
78
112
 
79
113
  ### Prior Art
80
114
 
@@ -28,6 +28,7 @@ module PdfForms
28
28
  end
29
29
  end
30
30
 
31
+ # pp 559 https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf
31
32
  def header
32
33
  header = "%FDF-1.2\n\n1 0 obj\n<<\n/FDF << /Fields 2 0 R"
33
34
 
@@ -39,13 +40,16 @@ module PdfForms
39
40
  header << "/ID[" << options[:id].join << "]" if options[:id]
40
41
 
41
42
  header << ">>\n>>\nendobj\n2 0 obj\n["
42
- return header
43
+ header
43
44
  end
44
45
 
46
+ # pp 561 https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf
45
47
  def field(key, value)
46
- "<</T(#{key})/V" +
47
- (Array === value ? "[#{value.map{ |v|"(#{quote(v)})" }.join}]" : "(#{quote(value)})") +
48
- ">>\n"
48
+ field = "<<"
49
+ field << "/T" + "(#{key})"
50
+ field << "/V" + (Array === value ? "[#{value.map{ |v|"(#{quote(v)})" }.join}]" : "(#{quote(value)})")
51
+ field << ">>\n"
52
+ field
49
53
  end
50
54
 
51
55
  def quote(value)
@@ -136,10 +136,17 @@ module PdfForms
136
136
  local[attrib] || options[attrib]
137
137
  end
138
138
 
139
+ ALLOWED_OPTIONS = %i(
140
+ drop_xmp
141
+ drop_xfa
142
+ flatten
143
+ need_appearances
144
+ ).freeze
145
+
139
146
  def append_options(args, local_options = {})
140
147
  return args if options.empty? && local_options.empty?
141
148
  args = args.dup
142
- %i(flatten drop_xfa drop_xmp).each do |option|
149
+ ALLOWED_OPTIONS.each do |option|
143
150
  if option_or_global(option, local_options)
144
151
  args << option.to_s
145
152
  end
@@ -1,5 +1,5 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  module PdfForms
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
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.2.0
4
+ version: 1.3.0
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: 2018-09-06 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cliver
@@ -93,7 +93,6 @@ files:
93
93
  - lib/pdf_forms/pdftk_wrapper.rb
94
94
  - lib/pdf_forms/version.rb
95
95
  - lib/pdf_forms/xfdf.rb
96
- - release.md
97
96
  homepage: http://github.com/jkraemer/pdf-forms
98
97
  licenses:
99
98
  - MIT
@@ -114,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
113
  version: 1.3.6
115
114
  requirements: []
116
115
  rubyforge_project: pdf-forms
117
- rubygems_version: 2.7.6
116
+ rubygems_version: 2.7.6.2
118
117
  signing_key:
119
118
  specification_version: 4
120
119
  summary: Fill out PDF forms with pdftk (http://www.accesspdf.com/pdftk/).
data/release.md DELETED
@@ -1,12 +0,0 @@
1
- https://wiki.debian.org/Creating%20signed%20GitHub%20releases
2
-
3
- * edit history and lib/pdf_forms/version.rb
4
- * commit
5
-
6
- ~~~~
7
- export version=1.3.0
8
- git tag -s ${version}
9
- git push --tags
10
- git archive --prefix="pdf-forms-${version}/" -o "../pdf-forms-${version}.tar.gz" ${version}
11
- gpg --armor --detach-sign "../pdf-forms-${version}.tar.gz"
12
- ~~~~