fillable-pdf 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/fillable-pdf.gemspec +1 -1
- data/lib/fillable-pdf.rb +20 -0
- data/lib/fillable-pdf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 476917341eb1db165e3aa0b7707c1db15ff37da3
|
4
|
+
data.tar.gz: 2b544131afb874e52e1d67dc0074cc66bafbc9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a59918324b552feb21632ce4f0c132659ba23685836717b9f7fbae4166bca6d80826e16cc1e84cd074155b3be1ee6a17085e2c357ee3308d407b8c80a8ff7c06
|
7
|
+
data.tar.gz: c61d56797285475ec09473fcd0896721aa84fa0955abee1cc2b848b656687ba4d8d67a847f1201625c23adb8cc451acc1327784a867130eac1119e37ca90923d
|
data/README.md
CHANGED
@@ -36,11 +36,15 @@ pdf = FillablePDF.new('input.pdf')
|
|
36
36
|
An instance of `FillablePDF` has the following methods at its disposal:
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
pdf.
|
39
|
+
pdf.has_fields? # returns true if the form has any fillable fields
|
40
40
|
|
41
|
-
pdf.
|
41
|
+
pdf.num_fields # get the total number of fillable form fields
|
42
42
|
|
43
|
-
pdf.
|
43
|
+
pdf.get_field('full_name') # retrieve a single field value by field name
|
44
|
+
|
45
|
+
pdf.set_field('first_name', 'Richard') # set a single field
|
46
|
+
|
47
|
+
pdf.set_fields({first_name: 'Richard', last_name: 'Rahl'}) # set multiple fields
|
44
48
|
```
|
45
49
|
|
46
50
|
Once the PDF is filled out you can either overwrite it or save it as another file:
|
@@ -48,7 +52,7 @@ Once the PDF is filled out you can either overwrite it or save it as another fil
|
|
48
52
|
```ruby
|
49
53
|
pdf.save
|
50
54
|
|
51
|
-
pdf.save_as(
|
55
|
+
pdf.save_as('output.pdf')
|
52
56
|
```
|
53
57
|
|
54
58
|
Or if you prefer to flatten the file (i.e. make it non-editable), you can instead use:
|
@@ -56,13 +60,13 @@ Or if you prefer to flatten the file (i.e. make it non-editable), you can instea
|
|
56
60
|
```ruby
|
57
61
|
pdf.save(true)
|
58
62
|
|
59
|
-
pdf.save_as(
|
63
|
+
pdf.save_as('output.pdf', true)
|
60
64
|
```
|
61
65
|
|
62
66
|
|
63
67
|
## Example
|
64
68
|
|
65
|
-
For a
|
69
|
+
For a fuller usage example of this gem, please see the contents of the `test` directory.
|
66
70
|
|
67
71
|
|
68
72
|
## Contributing
|
data/fillable-pdf.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = 'Fill out or extract field values from simple fillable PDF forms using iText.'
|
13
13
|
spec.description = 'FillablePDF is an extremely simple and lightweight utility that bridges iText and Ruby in order to fill out fillable PDF forms or extract field values from previously filled out PDF forms.'
|
14
|
-
spec.homepage = '
|
14
|
+
spec.homepage = 'https://vkononov.github.io/fillable-pdf'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/fillable-pdf.rb
CHANGED
@@ -26,6 +26,26 @@ class FillablePDF
|
|
26
26
|
end
|
27
27
|
|
28
28
|
|
29
|
+
##
|
30
|
+
# Determines whether the form has any fields.
|
31
|
+
#
|
32
|
+
# @return true if form has fields, false otherwise
|
33
|
+
#
|
34
|
+
def has_fields?
|
35
|
+
num_fields > 0
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
##
|
40
|
+
# Returns the total number of form fields.
|
41
|
+
#
|
42
|
+
# @return the number of fields
|
43
|
+
#
|
44
|
+
def num_fields
|
45
|
+
@form_fields.getFields.size
|
46
|
+
end
|
47
|
+
|
48
|
+
|
29
49
|
##
|
30
50
|
# Retrieves the value of a field given its unique field name.
|
31
51
|
#
|
data/lib/fillable-pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fillable-pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Kononov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- fillable-pdf.gemspec
|
73
73
|
- lib/fillable-pdf.rb
|
74
74
|
- lib/fillable-pdf/version.rb
|
75
|
-
homepage:
|
75
|
+
homepage: https://vkononov.github.io/fillable-pdf
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
78
|
metadata: {}
|