fillable-pdf 0.9.5.2 → 0.9.6

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: e0217f9c6c445e4d79c0a8af4514547beb6297ef401659993097a5bb4be57b14
4
- data.tar.gz: 6478016e8553f280217c0bc7f0a633f2cf8ac8aba6030639ef1a691d8b6d8aa7
3
+ metadata.gz: 29550c61e1d22f57a0df5eb9d2de4c01c49bed9f1ae36f96a7fd18889484d70d
4
+ data.tar.gz: a3616692065ea659cc7eb582450def4645d90e6c4cea87d74e35dfb3e68650df
5
5
  SHA512:
6
- metadata.gz: ff0ce41331cabc1b0cffc8aca6d5560e0a86855ad9cf1a705a1e5b15345c57e1e165c2a77b50f7fdc6c38e49f89308c1ffff851a98d14a9dbb0bdb735e994abd
7
- data.tar.gz: 3a2e98246b9d7ddbd617bfd0552e2e4891dac0d6ba241f85d23603cc139b88eb2c6a2d0570e73d1a5178dffd1b3e3923f0e9ca0b47b5d7d34c5bfa622e23f996
6
+ metadata.gz: 9d40a617f23bd04c4f36853e79131d5d378573c37ca71c97aed293fc55c0c39dbc38b28a2d3c7cb56c7be11c0dc8a0d207cce30a75677076787fb9a7caaedb07
7
+ data.tar.gz: b7c08116d5ea9721fb5b5a44be38b9ba7488b65e0b8020d148b5ae467b8b1c3319452871a7c61c1dbdca049c1ec55be41a68221fae1d943f72838c9d1c433b87
@@ -0,0 +1,24 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ name: Rubocop
13
+
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - name: Set up Ruby 3.2
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 3.2
20
+ bundler-cache: true
21
+ - name: Install dependencies
22
+ run: bundle install
23
+ - name: Run Rubocop
24
+ run: bin/lint --no-fix
@@ -1,31 +1,26 @@
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.
1
+ name: Test
5
2
 
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]
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
13
8
 
14
9
  jobs:
15
10
  test:
16
-
17
11
  runs-on: ubuntu-latest
18
-
12
+ name: Ruby ${{ matrix.ruby }}
19
13
  strategy:
20
14
  matrix:
21
- ruby-version: ['3.1', '3.0', '2.7', '2.6', '2.5', '2.4']
15
+ ruby: [ '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4' ]
22
16
 
23
17
  steps:
24
18
  - uses: actions/checkout@v3
25
- - name: Set up Ruby ${{ matrix.ruby-version }}
26
- uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
19
+ - name: Set up Ruby ${{ matrix.ruby }}
20
+ uses: ruby/setup-ruby@v1
27
21
  with:
28
- ruby-version: ${{ matrix.ruby-version }}
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
29
24
  - name: Install dependencies
30
25
  run: bundle install
31
26
  - name: Run tests
data/.rubocop.yml CHANGED
@@ -5,6 +5,7 @@ require:
5
5
  - rubocop-rake
6
6
 
7
7
  AllCops:
8
+ TargetRubyVersion: 2.4.0
8
9
  NewCops: enable
9
10
  Exclude:
10
11
  - .git/**/*
data/Gemfile CHANGED
@@ -1,3 +1,18 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+
8
+ # Code Linting
9
+ gem 'rubocop', require: false
10
+ gem 'rubocop-md', require: false
11
+ gem 'rubocop-minitest', require: false
12
+ gem 'rubocop-performance', require: false
13
+ gem 'rubocop-rake', require: false
14
+ end
15
+
16
+ group :test do
17
+ gem 'minitest'
18
+ end
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
  # FillablePDF
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/fillable-pdf.svg)](https://rubygems.org/gems/fillable-pdf)
5
- [![Test Status](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions)
5
+ [![Lint Status](https://github.com/vkononov/fillable-pdf/actions/workflows/lint.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions/workflows/lint.yml)
6
+ [![Test Status](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml/badge.svg)](https://github.com/vkononov/fillable-pdf/actions/workflows/test.yml)
6
7
 
7
8
  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
9
 
@@ -38,7 +39,7 @@ FillablePDF is an extremely simple and lightweight utility that bridges iText an
38
39
 
39
40
  ![Blank](images/checked.png)
40
41
 
41
- If only of the fields are blank, try setting the `generate_appearance` flag to `true` when calling `set_field` or `set_fields`.
42
+ If all of the fields are blank, try setting the `generate_appearance` flag to `true` when calling `set_field` or `set_fields`.
42
43
 
43
44
  ### Invalid Checkbox Appearances
44
45
 
@@ -175,17 +176,17 @@ An instance of `FillablePDF` has the following methods at its disposal:
175
176
  # output example: '/Btn'
176
177
 
177
178
  # list of all field types
178
- Field::BUTTON ('/Btn')
179
- Field::CHOICE ('/Ch')
180
- Field::SIGNATURE ('/Sig')
181
- Field::TEXT ('/Tx')
179
+ FillablePDF::Field::BUTTON ('/Btn')
180
+ FillablePDF::Field::CHOICE ('/Ch')
181
+ FillablePDF::Field::SIGNATURE ('/Sig')
182
+ FillablePDF::Field::TEXT ('/Tx')
182
183
  ```
183
184
 
184
185
  You can check the field type by using:
185
186
 
186
187
  ```ruby
187
- pdf.field_type(:football) == Field::BUTTON
188
- pdf.field_type('football') == Field::BUTTON
188
+ pdf.field_type(:football) == FillablePDF::Field::BUTTON
189
+ pdf.field_type('football') == FillablePDF::Field::BUTTON
189
190
  ```
190
191
 
191
192
  * `fields`
@@ -416,7 +417,7 @@ puts "Values: #{pdf.values}"
416
417
  puts
417
418
 
418
419
  # Checking field type
419
- if pdf.field_type(:rugby) == Field::BUTTON
420
+ if pdf.field_type(:rugby) == FillablePDF::Field::BUTTON
420
421
  puts "Field 'football' is of type BUTTON"
421
422
  else
422
423
  puts "Field 'football' is not of type BUTTON"
@@ -476,4 +477,4 @@ Removed field 'nascar'
476
477
 
477
478
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
478
479
 
479
- However, you must also adhere to the [iText License](https://github.com/itext/itext7) when using this gem in your project.
480
+ However, you must also adhere to the [iText License](https://github.com/itext/itext7) when using this gem in your project.
data/bin/lint ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env bash
2
+
3
+ RESET_COLOR='\033[0m'
4
+ HIGHLIGHT_COLOR='\033[0;35m'
5
+ SUCCESS_COLOR='\033[0;32m'
6
+ ERROR_COLOR='\033[0;31m'
7
+
8
+ clear
9
+
10
+ # linter configuration paths
11
+ RUBOCOP_CONFIG=.rubocop.yml
12
+
13
+ # Checking for existence of configuration files...
14
+ test -e ${RUBOCOP_CONFIG} || { echo -e "${ERROR_COLOR}"ERROR: ${RUBOCOP_CONFIG} not found."${RESET_COLOR}"; exit 1; }
15
+
16
+ # Running linters
17
+ echo -e "${HIGHLIGHT_COLOR}"Linting Ruby on Rails using RuboCop..."${RESET_COLOR}"
18
+ if [[ "$1" == "--no-fix" ]]; then
19
+ bundle exec rubocop || { valid=false; }
20
+ else
21
+ bundle exec rubocop --autocorrect-all || { valid=false; }
22
+ fi
23
+
24
+ # Printing summary
25
+ if [[ "$valid" == false ]]; then
26
+ echo -e "${ERROR_COLOR}"ERROR: Lint errors have been found in your code."${RESET_COLOR}"
27
+ exit 1
28
+ else
29
+ echo -e "${SUCCESS_COLOR}"SUCCESS: All lints have completed without errors."${RESET_COLOR}"
30
+ fi
data/fillable-pdf.gemspec CHANGED
@@ -21,15 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = %w[ext lib]
23
23
 
24
- spec.add_development_dependency 'bundler'
25
- spec.add_development_dependency 'minitest'
26
- spec.add_development_dependency 'rake'
27
- spec.add_development_dependency 'rubocop'
28
- spec.add_development_dependency 'rubocop-md'
29
- spec.add_development_dependency 'rubocop-minitest'
30
- spec.add_development_dependency 'rubocop-performance'
31
- spec.add_development_dependency 'rubocop-rake'
32
-
33
24
  spec.add_runtime_dependency 'rjb', '~> 1.6'
34
25
  spec.requirements << 'JDK 8.x - 11.x'
35
26
 
@@ -0,0 +1,15 @@
1
+ require_relative 'itext'
2
+
3
+ class FillablePDF
4
+ class Field
5
+ # PdfName has a constant "A" and a constant "a". Unfortunately, RJB does not differentiate
6
+ # between these constants and tries to create the same constant ("A") for both, which causes
7
+ # an annoying warning "already initialized constant Rjb::Com_itextpdf_kernel_pdf_PdfName::A".
8
+ # As long as RJB has not fixed this issue, this warning will remain suppressed.
9
+
10
+ BUTTON = ITEXT::PdfName.Btn.toString
11
+ CHOICE = ITEXT::PdfName.Ch.toString
12
+ SIGNATURE = ITEXT::PdfName.Sig.toString
13
+ TEXT = ITEXT::PdfName.Tx.toString
14
+ end
15
+ end
@@ -1,24 +1,28 @@
1
- require_relative 'kernel'
1
+ require_relative 'suppress_warnings'
2
2
  require 'rjb'
3
3
 
4
4
  Rjb.load(Dir.glob(File.expand_path('../../ext/*.jar', __dir__)).join(':'))
5
5
 
6
- module ITEXT
7
- suppress_warnings do
8
- ByteArrayOutputStream = Rjb.import 'com.itextpdf.io.source.ByteArrayOutputStream'
9
- Canvas = Rjb.import 'com.itextpdf.layout.Canvas'
10
- Div = Rjb.import 'com.itextpdf.layout.element.Div'
11
- HorizontalAlignment = Rjb.import 'com.itextpdf.layout.properties.HorizontalAlignment'
12
- Image = Rjb.import 'com.itextpdf.layout.element.Image'
13
- ImageDataFactory = Rjb.import 'com.itextpdf.io.image.ImageDataFactory'
14
- PdfAcroForm = Rjb.import 'com.itextpdf.forms.PdfAcroForm'
15
- PdfDictionary = Rjb.import 'com.itextpdf.kernel.pdf.PdfDictionary'
16
- PdfDocument = Rjb.import 'com.itextpdf.kernel.pdf.PdfDocument'
17
- PdfFormXObject = Rjb.import 'com.itextpdf.kernel.pdf.xobject.PdfFormXObject'
18
- PdfName = Rjb.import 'com.itextpdf.kernel.pdf.PdfName'
19
- PdfReader = Rjb.import 'com.itextpdf.kernel.pdf.PdfReader'
20
- PdfWriter = Rjb.import 'com.itextpdf.kernel.pdf.PdfWriter'
21
- Rectangle = Rjb.import 'com.itextpdf.kernel.geom.Rectangle'
22
- VerticalAlignment = Rjb.import 'com.itextpdf.layout.properties.VerticalAlignment'
6
+ class FillablePDF
7
+ module ITEXT
8
+ extend FillablePDF::SuppressWarnings
9
+
10
+ suppress_warnings do
11
+ ByteArrayOutputStream = Rjb.import 'com.itextpdf.io.source.ByteArrayOutputStream'
12
+ Canvas = Rjb.import 'com.itextpdf.layout.Canvas'
13
+ Div = Rjb.import 'com.itextpdf.layout.element.Div'
14
+ HorizontalAlignment = Rjb.import 'com.itextpdf.layout.properties.HorizontalAlignment'
15
+ Image = Rjb.import 'com.itextpdf.layout.element.Image'
16
+ ImageDataFactory = Rjb.import 'com.itextpdf.io.image.ImageDataFactory'
17
+ PdfAcroForm = Rjb.import 'com.itextpdf.forms.PdfAcroForm'
18
+ PdfDictionary = Rjb.import 'com.itextpdf.kernel.pdf.PdfDictionary'
19
+ PdfDocument = Rjb.import 'com.itextpdf.kernel.pdf.PdfDocument'
20
+ PdfFormXObject = Rjb.import 'com.itextpdf.kernel.pdf.xobject.PdfFormXObject'
21
+ PdfName = Rjb.import 'com.itextpdf.kernel.pdf.PdfName'
22
+ PdfReader = Rjb.import 'com.itextpdf.kernel.pdf.PdfReader'
23
+ PdfWriter = Rjb.import 'com.itextpdf.kernel.pdf.PdfWriter'
24
+ Rectangle = Rjb.import 'com.itextpdf.kernel.geom.Rectangle'
25
+ VerticalAlignment = Rjb.import 'com.itextpdf.layout.properties.VerticalAlignment'
26
+ end
23
27
  end
24
28
  end
@@ -0,0 +1,11 @@
1
+ class FillablePDF
2
+ module SuppressWarnings
3
+ def suppress_warnings
4
+ original_verbosity = $VERBOSE
5
+ $VERBOSE = nil
6
+ result = yield
7
+ $VERBOSE = original_verbosity
8
+ result
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  class FillablePDF
2
- VERSION = '0.9.5.2'
2
+ VERSION = '0.9.6'
3
3
  end
data/lib/fillable-pdf.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  require_relative 'fillable-pdf/itext'
2
- require_relative 'field'
2
+ require_relative 'fillable-pdf/suppress_warnings'
3
+ require_relative 'fillable-pdf/field'
3
4
  require 'base64'
4
5
  require 'securerandom'
5
6
  require 'tmpdir'
6
7
 
7
8
  class FillablePDF # rubocop:disable Metrics/ClassLength
9
+ include SuppressWarnings
10
+
8
11
  ##
9
12
  # Opens a given fillable-pdf PDF file and prepares it for modification.
10
13
  #
metadata CHANGED
@@ -1,127 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fillable-pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5.2
4
+ version: 0.9.6
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-12-05 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-md
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-minitest
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-performance
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
13
  - !ruby/object:Gem::Dependency
126
14
  name: rjb
127
15
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +33,7 @@ executables: []
145
33
  extensions: []
146
34
  extra_rdoc_files: []
147
35
  files:
36
+ - ".github/workflows/lint.yml"
148
37
  - ".github/workflows/test.yml"
149
38
  - ".gitignore"
150
39
  - ".rubocop.yml"
@@ -153,6 +42,7 @@ files:
153
42
  - README.md
154
43
  - Rakefile
155
44
  - bin/console
45
+ - bin/lint
156
46
  - bin/setup
157
47
  - ext/commons-7.2.4.jar
158
48
  - ext/font-asian-7.2.4.jar
@@ -166,10 +56,10 @@ files:
166
56
  - images/blank.png
167
57
  - images/checked.png
168
58
  - images/distinct.png
169
- - lib/field.rb
170
59
  - lib/fillable-pdf.rb
60
+ - lib/fillable-pdf/field.rb
171
61
  - lib/fillable-pdf/itext.rb
172
- - lib/fillable-pdf/kernel.rb
62
+ - lib/fillable-pdf/suppress_warnings.rb
173
63
  - lib/fillable-pdf/version.rb
174
64
  homepage: https://github.com/vkononov/fillable-pdf
175
65
  licenses:
@@ -193,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
83
  version: '0'
194
84
  requirements:
195
85
  - JDK 8.x - 11.x
196
- rubygems_version: 3.3.7
86
+ rubygems_version: 3.4.16
197
87
  signing_key:
198
88
  specification_version: 4
199
89
  summary: Fill out or extract field values from simple fillable PDF forms using iText.
data/lib/field.rb DELETED
@@ -1,13 +0,0 @@
1
- require_relative 'fillable-pdf/itext'
2
-
3
- class Field
4
- # PdfName has a constant "A" and a constant "a". Unfortunately, RJB does not differentiate
5
- # between these constants and tries to create the same constant ("A") for both, which causes
6
- # an annoying warning "already initialized constant Rjb::Com_itextpdf_kernel_pdf_PdfName::A".
7
- # As long as RJB has not fixed this issue, this warning will remain suppressed.
8
-
9
- BUTTON = ITEXT::PdfName.Btn.toString
10
- CHOICE = ITEXT::PdfName.Ch.toString
11
- SIGNATURE = ITEXT::PdfName.Sig.toString
12
- TEXT = ITEXT::PdfName.Tx.toString
13
- end
@@ -1,9 +0,0 @@
1
- module Kernel
2
- def suppress_warnings
3
- original_verbosity = $VERBOSE
4
- $VERBOSE = nil
5
- result = yield
6
- $VERBOSE = original_verbosity
7
- result
8
- end
9
- end