pdf-forms 0.5.8 → 0.6.0
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/README.md +6 -6
- data/lib/pdf_forms/field.rb +22 -10
- data/lib/pdf_forms/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dafa2a5c9130fc6e580251237c45d7c423f4e178
|
4
|
+
data.tar.gz: ade160fa891ee6d433f0d8baedb404eee2750d44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de0909cb12fc43557003d02b6fc972ee2fad1916da68b318d52df36b3fa5bb3aabd7055d6c0e9744d6f0f92c4c74a731cc87fc4e5a36de96773a27c8958620ed
|
7
|
+
data.tar.gz: 8f0eadfcdd96afa187303644909c5db91de9c18771731aebd2a89cac98fa63ac13289b62c7e0677428879ad484a39098c1fd5ebb63f816b0295e7227b2e4a2bb
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ unusual here.
|
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
require 'pdf_forms'
|
26
|
-
fdf
|
26
|
+
fdf = PdfForms::Fdf.new :key => 'value', :other_key => 'other value'
|
27
27
|
# use to_pdf_data if you just want the fdf data, without writing it to a file
|
28
28
|
puts fdf.to_pdf_data
|
29
29
|
# write fdf file
|
@@ -38,22 +38,22 @@ To generate XFDF instead of FDF instantiate `PdfForms::XFdf` instead of `PdfForm
|
|
38
38
|
require 'pdf_forms'
|
39
39
|
|
40
40
|
# adjust the pdftk path to suit your pdftk installation
|
41
|
-
# add :data_format
|
41
|
+
# add :data_format => 'XFdf' option to generate XFDF instead of FDF when
|
42
42
|
# filling a form (XFDF is supposed to have better support for non-western
|
43
43
|
# encodings)
|
44
|
-
# add :utf8_fields
|
44
|
+
# add :utf8_fields => true in order to get UTF8 encoded field metadata (this
|
45
45
|
# will use dump_data_fields_utf8 instead of dump_data_fields in the call to
|
46
46
|
# pdftk)
|
47
|
-
pdftk
|
47
|
+
pdftk = PdfForms.new('/usr/local/bin/pdftk')
|
48
48
|
|
49
49
|
# find out the field names that are present in form.pdf
|
50
50
|
pdftk.get_field_names 'path/to/form.pdf'
|
51
51
|
|
52
52
|
# take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
|
53
|
-
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', :foo
|
53
|
+
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', :foo => 'bar'
|
54
54
|
|
55
55
|
# optionally, add the :flatten option to prevent editing of a filled out form
|
56
|
-
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {:foo
|
56
|
+
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {:foo => 'bar'}, :flatten => true
|
57
57
|
```
|
58
58
|
|
59
59
|
### Prior Art
|
data/lib/pdf_forms/field.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module PdfForms
|
4
4
|
class Field
|
5
|
-
|
6
5
|
# FieldType: Button
|
7
6
|
# FieldName: Sprachoptionen_Inverssuche_Widerspruch
|
8
7
|
# FieldFlags: 0
|
@@ -17,20 +16,33 @@ module PdfForms
|
|
17
16
|
when /FieldStateOption:\s*(.*?)\s*$/
|
18
17
|
(@options ||= []) << $1
|
19
18
|
else
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
line.strip!
|
20
|
+
key, value = line.split(": ")
|
21
|
+
key.gsub!(/Field/, "")
|
22
|
+
key = key.split(/(?=[A-Z])/).map(&:downcase).join('_').split(":")[0]
|
23
|
+
|
24
|
+
instance_variable_set("@#{key}", value)
|
25
|
+
|
26
|
+
# dynamically add in fields that we didn't anticipate in ATTRS
|
27
|
+
unless self.respond_to?(key.to_sym)
|
28
|
+
proc = Proc.new { instance_variable_get("@#{key}".to_sym) }
|
29
|
+
self.class.send(:define_method, key.to_sym, proc)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
34
|
+
|
35
|
+
def to_hash
|
36
|
+
hash = {}
|
37
|
+
ATTRS.each do |attribute|
|
38
|
+
hash[attribute] = self.send(attribute)
|
39
|
+
end
|
40
|
+
|
41
|
+
hash
|
42
|
+
end
|
32
43
|
|
33
44
|
# Common Fields
|
34
|
-
|
45
|
+
ATTRS = [:name, :type, :options, :flags, :justification, :value, :value_default, :name_alt, :max_length]
|
46
|
+
ATTRS.each {|attribute| attr_reader attribute}
|
35
47
|
end
|
36
48
|
end
|
data/lib/pdf_forms/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.6.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: 2014-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby frontend to the pdftk binary, including FDF and XFDF creation.
|
14
14
|
Just pass your template and a hash of data to fill in.
|
@@ -40,12 +40,12 @@ require_paths:
|
|
40
40
|
- lib
|
41
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - '>='
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 1.3.6
|
51
51
|
requirements: []
|