fillable-pdf 0.9.4 → 0.9.5

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: 3295f6a5e77e53fb9ae16f59cb1456483daecf203857cd903fd84622336f9d35
4
- data.tar.gz: 4bb925c8f5908f663d36f93afb701c2dc5dcd744f476a50b2bf17fc73ff97f6d
3
+ metadata.gz: 9cc8f575f9b31b18057031e15fc16d37fd65b41e28668bc9e11a8dba241d9722
4
+ data.tar.gz: 74f1e13956bf1c555c449602456fa01c237c0d3853934741f7c03e914c488a42
5
5
  SHA512:
6
- metadata.gz: ae5c10683e12cda0c209126d256b6f223d2b4194c85b06be9af9e76c12a710c8fe5d8fe6b3ff646d0b285ff93d0f97a8a0bd0c655474b52746a7c43460fd7925
7
- data.tar.gz: a793a4b88d8034f9d3194fd19c07244c4d1083477f9004307208c1b9b23764fc0dde863f6f2a54c0abb264c90f5b2d05360b850fbc074afe9f259d4f51a449cf
6
+ metadata.gz: 7543225bc5bacb607026100289a2c3ab349bced197d9077b2f00eb1c2a13c48da21979d007f7c02b1bbbd81caa036102d2ed15e4e1cc0f1b625153f5be90202b
7
+ data.tar.gz: 65d5d86a9e48494a5adcb168e063d0e73e1e4ff8eb85900571341f1c90ed32cc4a24d103c7f455b1a2ebffb8a70832443d5bef09f2779549326ed6c0e0a9f0a5
@@ -0,0 +1,32 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+
6
+ # GitHub recommends pinning actions to a commit SHA.
7
+ # To get a newer version, you will need to update the SHA.
8
+ # You can also reference a tag or branch, but the action may change without warning.
9
+
10
+ name: test
11
+
12
+ on: [push, pull_request]
13
+
14
+ jobs:
15
+ test:
16
+
17
+ runs-on: ubuntu-latest
18
+
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ['3.1', '3.0', '2.7', '2.6', '2.5', '2.4']
22
+
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - name: Set up Ruby ${{ matrix.ruby-version }}
26
+ uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ - name: Install dependencies
30
+ run: bundle install
31
+ - name: Run tests
32
+ run: bundle exec rake test
data/.rubocop.yml CHANGED
@@ -55,5 +55,8 @@ Style/FrozenStringLiteralComment:
55
55
  Style/GuardClause:
56
56
  Enabled: false
57
57
 
58
+ Style/HashSyntax:
59
+ Enabled: false
60
+
58
61
  Style/MutableConstant:
59
62
  Enabled: false
data/README.md CHANGED
@@ -2,30 +2,34 @@
2
2
  # FillablePDF
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/fillable-pdf.svg)](https://rubygems.org/gems/fillable-pdf)
5
- [![Build Status](https://app.travis-ci.com/vkononov/fillable-pdf.svg?branch=master)](http://travis-ci.org/vkononov/fillable-pdf)
5
+ [![Test Status](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions)
6
6
 
7
7
  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.
8
8
 
9
9
 
10
10
  ## Known Issues
11
11
 
12
- 1. This gem currently does not work with Phusion Passenger's [smart spawning](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#the-smart-spawning-method). Please see [Deployment with Phusion Passenger + Nginx](#deployment-with-phusion-passenger--nginx) for more information.
12
+ 1. Phusion Passenger's [smart spawning](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#the-smart-spawning-method) is not supported. Please see [Deployment with Phusion Passenger + Nginx](#deployment-with-phusion-passenger--nginx) for more information.
13
13
 
14
- 2. If the gem hangs in `development`, removing the following gems may fix the issue:
14
+ 2. Puma workers (process forking) is not supposed due to an [issue](https://github.com/arton/rjb/issues/88) with the [rjb](https://github.com/arton/rjb) gem dependency.
15
+
16
+ 3. If the gem hangs in `development`, removing the following gems may fix the issue:
15
17
 
16
18
  ```ruby
17
19
  gem 'spring'
18
20
  gem 'spring-watcher-listen'
19
21
  ```
20
22
 
21
- 3. Read-only, write-protected or encrypted PDF files are currently not supported.
23
+ 4. Read-only, write-protected or encrypted PDF files are currently not supported.
24
+
25
+ 5. Adobe generated field arrays (i.e. fields with names such as `array.0` or `array.1.0`) are not supported.
22
26
 
23
27
 
24
28
  ## Installation
25
29
 
26
30
  **Prerequisites:** Java SE Development Kit v8, v11
27
31
 
28
- - Ensure that your `JAVA_HOME` variable is set before installing this gem (see examples below).**
32
+ - Ensure that your `JAVA_HOME` variable is set before installing this gem (see examples below).
29
33
 
30
34
  * OSX: `/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home`
31
35
  * Ubuntu/CentOS: `/usr/lib/jvm/java-1.8.0-openjdk`
@@ -135,7 +139,7 @@ An instance of `FillablePDF` has the following methods at its disposal:
135
139
  ```
136
140
 
137
141
  * `field_type`
138
- *Retrieves the numeric type of a field given its unique field name.*
142
+ *Retrieves the string type of a field given its unique field name.*
139
143
 
140
144
  ```ruby
141
145
  pdf.field_type(:football)
@@ -148,6 +152,12 @@ An instance of `FillablePDF` has the following methods at its disposal:
148
152
  Field::TEXT ('/Tx')
149
153
  ```
150
154
 
155
+ You can check the field type by using:
156
+
157
+ ```ruby
158
+ pdf.field_type(:football) == Field::BUTTON
159
+ ```
160
+
151
161
  * `fields`
152
162
  *Retrieves a hash of all fields and their values.*
153
163
 
@@ -1,3 +1,3 @@
1
1
  class FillablePDF
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  end
data/lib/fillable-pdf.rb CHANGED
@@ -10,7 +10,7 @@ class FillablePDF # rubocop:disable Metrics/ClassLength
10
10
  #
11
11
  # @param [String|Symbol] file_path the name of the PDF file or file path
12
12
  #
13
- def initialize(file_path) # rubocop:disable Metrics/MethodLength
13
+ def initialize(file_path)
14
14
  raise IOError, "File <#{file_path}> is not found" unless File.exist?(file_path)
15
15
  @file_path = file_path
16
16
  begin
@@ -20,7 +20,6 @@ class FillablePDF # rubocop:disable Metrics/ClassLength
20
20
  @pdf_doc = ITEXT::PdfDocument.new @pdf_reader, @pdf_writer
21
21
  @pdf_form = ITEXT::PdfAcroForm.getAcroForm(@pdf_doc, true)
22
22
  @form_fields = @pdf_form.getFormFields
23
- @pdf_form.setGenerateAppearance false
24
23
  rescue StandardError => e
25
24
  raise "#{e.message} (Input file may be corrupt, incompatible, read-only, write-protected, encrypted, or may not have any form fields)" # rubocop:disable Layout/LineLength
26
25
  end
@@ -58,7 +57,7 @@ class FillablePDF # rubocop:disable Metrics/ClassLength
58
57
  end
59
58
 
60
59
  ##
61
- # Retrieves the numeric type of a field given its unique field name.
60
+ # Retrieves the string type of a field given its unique field name.
62
61
  #
63
62
  # @param [String|Symbol] key the field name
64
63
  #
@@ -90,7 +89,10 @@ class FillablePDF # rubocop:disable Metrics/ClassLength
90
89
  # @param [String|Symbol] value the field value
91
90
  #
92
91
  def set_field(key, value)
93
- pdf_field(key).setValue(value.to_s)
92
+ # we set generate_appearance to false for buttons to ensure that the chosen
93
+ # appearance for checkboxes (i.e. check, circle, diamond) is not changed
94
+ generate_appearance = field_type(key) != Field::BUTTON
95
+ pdf_field(key).setValue(value.to_s, generate_appearance)
94
96
  end
95
97
 
96
98
  ##
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.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Kononov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-14 00:00:00.000000000 Z
11
+ date: 2022-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,9 +145,9 @@ executables: []
145
145
  extensions: []
146
146
  extra_rdoc_files: []
147
147
  files:
148
+ - ".github/workflows/test.yml"
148
149
  - ".gitignore"
149
150
  - ".rubocop.yml"
150
- - ".travis.yml"
151
151
  - Gemfile
152
152
  - LICENSE.md
153
153
  - README.md
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  requirements:
192
192
  - JDK 8.x - 11.x
193
- rubygems_version: 3.3.7
193
+ rubygems_version: 3.1.4
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Fill out or extract field values from simple fillable PDF forms using iText.
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 3.0.3
7
- jdk:
8
- - openjdk8
9
- before_install:
10
- - gem install bundler