fillable-pdf 1.0.0 → 1.0.1
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/.github/workflows/test.yml +5 -3
- data/README.md +55 -1
- data/fillable-pdf.gemspec +1 -0
- data/lib/fillable-pdf/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7546695fbeb3213a736f94e783a85ddb1a60f9b54e2bacf47470f26edcd2b509
|
|
4
|
+
data.tar.gz: fe054623093ec69d7e6b8ef5c705963a56ed26054f26c00ff5669cbd7752a540
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97c0a10edf7d8998c227f3a979dbdff318b77fe63eb51a9482d6c5436311589ee7dd675ddd5457b4e2f6d9dda65abd4191994c80cf8db93113bed2a743774b55
|
|
7
|
+
data.tar.gz: a78d845c56c35dfdaac5c71e09e4ff0306c807b95f368f55813a9b2cb2fb545e6534d6ca33cdd1d0d86fbd7e524f38abc5c544d118006f529ce359ddb0acfc77
|
data/.github/workflows/test.yml
CHANGED
|
@@ -3,8 +3,10 @@ name: Test
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
6
|
+
- main
|
|
7
7
|
pull_request:
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: '0 0 * * *'
|
|
8
10
|
|
|
9
11
|
jobs:
|
|
10
12
|
test:
|
|
@@ -13,8 +15,8 @@ jobs:
|
|
|
13
15
|
strategy:
|
|
14
16
|
fail-fast: false
|
|
15
17
|
matrix:
|
|
16
|
-
ruby: [ '3.4', '3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4' ]
|
|
17
|
-
java: [ '8', '11', '17', '21', '23' ]
|
|
18
|
+
ruby: [ '4.0', '3.4', '3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4' ]
|
|
19
|
+
java: [ '8', '11', '17', '21', '23', '25' ]
|
|
18
20
|
|
|
19
21
|
steps:
|
|
20
22
|
- uses: actions/checkout@v4
|
data/README.md
CHANGED
|
@@ -103,6 +103,18 @@ pdf = FillablePDF.new 'input.pdf'
|
|
|
103
103
|
pdf.close
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
### Method Chaining
|
|
107
|
+
|
|
108
|
+
All setter methods return `self`, allowing you to chain operations:
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
pdf.set_field(:first_name, 'Richard')
|
|
112
|
+
.set_field(:last_name, 'Rahl')
|
|
113
|
+
.set_field(:date, Time.now.strftime('%B %e, %Y'))
|
|
114
|
+
.save
|
|
115
|
+
.close
|
|
116
|
+
```
|
|
117
|
+
|
|
106
118
|
### Checking / Unchecking Checkboxes
|
|
107
119
|
|
|
108
120
|
Use the values `'Yes'` and `'Off'` to check and uncheck checkboxes, respectively. For example:
|
|
@@ -290,7 +302,7 @@ An instance of `FillablePDF` has the following methods at its disposal:
|
|
|
290
302
|
```ruby
|
|
291
303
|
pdf.save
|
|
292
304
|
# result: document is saved without flattening
|
|
293
|
-
pdf.
|
|
305
|
+
pdf.save(flatten: true)
|
|
294
306
|
# result: document is saved with flattening
|
|
295
307
|
```
|
|
296
308
|
|
|
@@ -335,6 +347,48 @@ An instance of `FillablePDF` has the following methods at its disposal:
|
|
|
335
347
|
# output example: true
|
|
336
348
|
```
|
|
337
349
|
|
|
350
|
+
## Error Handling
|
|
351
|
+
|
|
352
|
+
The gem raises custom error classes for different error conditions, making it easier to catch specific problems:
|
|
353
|
+
|
|
354
|
+
```ruby
|
|
355
|
+
begin
|
|
356
|
+
pdf = FillablePDF.new('input.pdf')
|
|
357
|
+
pdf.field(:nonexistent_field)
|
|
358
|
+
rescue FillablePDF::FieldNotFoundError => e
|
|
359
|
+
puts "Field not found: #{e.message}"
|
|
360
|
+
rescue FillablePDF::InvalidArgumentError => e
|
|
361
|
+
puts "Invalid input: #{e.message}"
|
|
362
|
+
rescue FillablePDF::FileOperationError => e
|
|
363
|
+
puts "File error: #{e.message}"
|
|
364
|
+
rescue FillablePDF::Error => e
|
|
365
|
+
puts "General error: #{e.message}"
|
|
366
|
+
end
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Error Classes
|
|
370
|
+
|
|
371
|
+
- **`FillablePDF::Error`** - Base class for all gem errors
|
|
372
|
+
- **`FillablePDF::FieldNotFoundError`** - Raised when a field doesn't exist in the PDF
|
|
373
|
+
- **`FillablePDF::InvalidArgumentError`** - Raised when invalid arguments are provided
|
|
374
|
+
- **`FillablePDF::FileOperationError`** - Raised when file operations fail (file not found, cannot save, etc.)
|
|
375
|
+
|
|
376
|
+
### Common Error Scenarios
|
|
377
|
+
|
|
378
|
+
```ruby
|
|
379
|
+
# Field doesn't exist
|
|
380
|
+
pdf.field(:nonexistent) # raises FieldNotFoundError
|
|
381
|
+
|
|
382
|
+
# Invalid input
|
|
383
|
+
pdf.set_field(:name, nil) # raises InvalidArgumentError
|
|
384
|
+
|
|
385
|
+
# File not found
|
|
386
|
+
pdf = FillablePDF.new('missing.pdf') # raises FileOperationError
|
|
387
|
+
|
|
388
|
+
# Operations on closed document
|
|
389
|
+
pdf.close
|
|
390
|
+
pdf.set_field(:name, 'test') # raises FileOperationError
|
|
391
|
+
```
|
|
338
392
|
|
|
339
393
|
## Deployment with Heroku
|
|
340
394
|
|
data/fillable-pdf.gemspec
CHANGED
data/lib/fillable-pdf/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fillable-pdf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vadim Kononov
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0.1'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: fiddle
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.0'
|
|
26
40
|
- !ruby/object:Gem::Dependency
|
|
27
41
|
name: rjb
|
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -97,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
97
111
|
version: '0'
|
|
98
112
|
requirements:
|
|
99
113
|
- JDK >= 8
|
|
100
|
-
rubygems_version:
|
|
114
|
+
rubygems_version: 4.0.3
|
|
101
115
|
specification_version: 4
|
|
102
116
|
summary: Fill out or extract field values from simple fillable PDF forms using iText.
|
|
103
117
|
test_files: []
|