fillable-pdf 0.9.3 → 0.9.4
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 +65 -62
- data/ext/commons-7.2.3.jar +0 -0
- data/ext/{font-asian-7.1.17.jar → font-asian-7.2.3.jar} +0 -0
- data/ext/forms-7.2.3.jar +0 -0
- data/ext/io-7.2.3.jar +0 -0
- data/ext/kernel-7.2.3.jar +0 -0
- data/ext/layout-7.2.3.jar +0 -0
- data/fillable-pdf.gemspec +2 -1
- data/lib/fillable-pdf/itext.rb +2 -2
- data/lib/fillable-pdf/version.rb +1 -1
- data/lib/fillable-pdf.rb +3 -2
- metadata +15 -13
- data/ext/forms-7.1.17.jar +0 -0
- data/ext/io-7.1.17.jar +0 -0
- data/ext/kernel-7.1.17.jar +0 -0
- data/ext/layout-7.1.17.jar +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3295f6a5e77e53fb9ae16f59cb1456483daecf203857cd903fd84622336f9d35
         | 
| 4 | 
            +
              data.tar.gz: 4bb925c8f5908f663d36f93afb701c2dc5dcd744f476a50b2bf17fc73ff97f6d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ae5c10683e12cda0c209126d256b6f223d2b4194c85b06be9af9e76c12a710c8fe5d8fe6b3ff646d0b285ff93d0f97a8a0bd0c655474b52746a7c43460fd7925
         | 
| 7 | 
            +
              data.tar.gz: a793a4b88d8034f9d3194fd19c07244c4d1083477f9004307208c1b9b23764fc0dde863f6f2a54c0abb264c90f5b2d05360b850fbc074afe9f259d4f51a449cf
         | 
    
        data/README.md
    CHANGED
    
    | @@ -20,72 +20,15 @@ FillablePDF is an extremely simple and lightweight utility that bridges iText an | |
| 20 20 |  | 
| 21 21 | 
             
            3. Read-only, write-protected or encrypted PDF files are currently not supported.
         | 
| 22 22 |  | 
| 23 | 
            -
            ## Deployment with Heroku
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            When deploying to Heroku, be sure to install the following build packs (in this order):
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            ```bash
         | 
| 28 | 
            -
            heroku buildpacks:add heroku/jvm
         | 
| 29 | 
            -
            heroku buildpacks:add heroku/ruby
         | 
| 30 | 
            -
            ```
         | 
| 31 | 
            -
             | 
| 32 | 
            -
            ## Deployment with Phusion Passenger + Nginx
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            The way the gem is currently built makes it [fundamentally incompatible](https://github.com/phusion/passenger/issues/223#issuecomment-44504029) with Phusion Passenger's [smart spawning](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#the-smart-spawning-method). You must turn off smart spawning, or else your application will freeze as soon Ruby tries to access the Java bridge.
         | 
| 35 | 
            -
             | 
| 36 | 
            -
            Below is an example of a simple Nginx virtual host configuration (note the use of `passenger_spawn_method`):
         | 
| 37 | 
            -
             | 
| 38 | 
            -
            ```nginx
         | 
| 39 | 
            -
            server {
         | 
| 40 | 
            -
                server_name my-rails-app.com;
         | 
| 41 | 
            -
                listen 443 ssl http2;
         | 
| 42 | 
            -
                listen [::]:443 ssl http2;
         | 
| 43 | 
            -
                passenger_enabled on;
         | 
| 44 | 
            -
                passenger_spawn_method direct;
         | 
| 45 | 
            -
                root /home/system/my-rails-app/public;
         | 
| 46 | 
            -
            }
         | 
| 47 | 
            -
            ```
         | 
| 48 | 
            -
             | 
| 49 | 
            -
            If you absolutely must have smart spawning, I recommend using `fillable-pdf` as a service that runs independently of your Rails application.
         | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
            ## Deployment with Puma + Nginx
         | 
| 53 | 
            -
             | 
| 54 | 
            -
            In order to use Puma in production, you need to configure a reverse proxy in your Nginx virtual host. Here is simple naive example:
         | 
| 55 | 
            -
             | 
| 56 | 
            -
            ```nginx
         | 
| 57 | 
            -
            server {
         | 
| 58 | 
            -
                server_name my-rails-app.com;
         | 
| 59 | 
            -
                listen 443 ssl http2;
         | 
| 60 | 
            -
                listen [::]:443 ssl http2;
         | 
| 61 | 
            -
                location / {
         | 
| 62 | 
            -
                    proxy_pass http://127.0.0.1:8888;
         | 
| 63 | 
            -
                    proxy_redirect off;
         | 
| 64 | 
            -
                    proxy_set_header Connection "upgrade";
         | 
| 65 | 
            -
                    proxy_set_header Host $http_host;
         | 
| 66 | 
            -
                    proxy_set_header Upgrade $http_upgrade;
         | 
| 67 | 
            -
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         | 
| 68 | 
            -
                    proxy_set_header X-Forwarded-Proto https;
         | 
| 69 | 
            -
                    proxy_set_header X-Real-IP $remote_addr;
         | 
| 70 | 
            -
                }
         | 
| 71 | 
            -
            }
         | 
| 72 | 
            -
            ```
         | 
| 73 | 
            -
             | 
| 74 | 
            -
            Then you'll have to start Puma in production daemon mode as follows:
         | 
| 75 | 
            -
             | 
| 76 | 
            -
            ```bash
         | 
| 77 | 
            -
            RAILS_ENV=production bin/rails server -p 8888 --daemon
         | 
| 78 | 
            -
            ```
         | 
| 79 | 
            -
             | 
| 80 | 
            -
            Naturally, there are many downsides (in terms of efficiency, scalability, security, etc) to running your application in production in this manner, so please use the above as an example only.
         | 
| 81 | 
            -
             | 
| 82 23 |  | 
| 83 24 | 
             
            ## Installation
         | 
| 84 25 |  | 
| 85 | 
            -
            ** | 
| 26 | 
            +
            **Prerequisites:** Java SE Development Kit v8, v11
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            - Ensure that your `JAVA_HOME` variable is set before installing this gem (see examples below).**
         | 
| 86 29 |  | 
| 87 | 
            -
            * OSX: `/Library/Java/JavaVirtualMachines/jdk- | 
| 88 | 
            -
            * Ubuntu/CentOS: `/usr/lib/jvm/java-1.8.0-openjdk`
         | 
| 30 | 
            +
              * OSX: `/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home`
         | 
| 31 | 
            +
              * Ubuntu/CentOS: `/usr/lib/jvm/java-1.8.0-openjdk`
         | 
| 89 32 |  | 
| 90 33 | 
             
            Add this line to your application's Gemfile:
         | 
| 91 34 |  | 
| @@ -308,6 +251,66 @@ An instance of `FillablePDF` has the following methods at its disposal: | |
| 308 251 | 
             
                # result: document is closed
         | 
| 309 252 | 
             
                ```
         | 
| 310 253 |  | 
| 254 | 
            +
             | 
| 255 | 
            +
            ## Deployment with Heroku
         | 
| 256 | 
            +
             | 
| 257 | 
            +
            When deploying to Heroku, be sure to install the following build packs (in this order):
         | 
| 258 | 
            +
             | 
| 259 | 
            +
            ```bash
         | 
| 260 | 
            +
            heroku buildpacks:add heroku/jvm
         | 
| 261 | 
            +
            heroku buildpacks:add heroku/ruby
         | 
| 262 | 
            +
            ```
         | 
| 263 | 
            +
             | 
| 264 | 
            +
            ## Deployment with Phusion Passenger + Nginx
         | 
| 265 | 
            +
             | 
| 266 | 
            +
            The way the gem is currently built makes it [fundamentally incompatible](https://github.com/phusion/passenger/issues/223#issuecomment-44504029) with Phusion Passenger's [smart spawning](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#the-smart-spawning-method). You must turn off smart spawning, or else your application will freeze as soon Ruby tries to access the Java bridge.
         | 
| 267 | 
            +
             | 
| 268 | 
            +
            Below is an example of a simple Nginx virtual host configuration (note the use of `passenger_spawn_method`):
         | 
| 269 | 
            +
             | 
| 270 | 
            +
            ```nginx
         | 
| 271 | 
            +
            server {
         | 
| 272 | 
            +
                server_name my-rails-app.com;
         | 
| 273 | 
            +
                listen 443 ssl http2;
         | 
| 274 | 
            +
                listen [::]:443 ssl http2;
         | 
| 275 | 
            +
                passenger_enabled on;
         | 
| 276 | 
            +
                passenger_spawn_method direct;
         | 
| 277 | 
            +
                root /home/system/my-rails-app/public;
         | 
| 278 | 
            +
            }
         | 
| 279 | 
            +
            ```
         | 
| 280 | 
            +
             | 
| 281 | 
            +
            If you absolutely must have smart spawning, I recommend using `fillable-pdf` as a service that runs independently of your Rails application.
         | 
| 282 | 
            +
             | 
| 283 | 
            +
            ## Deployment with Puma + Nginx
         | 
| 284 | 
            +
             | 
| 285 | 
            +
            In order to use Puma in production, you need to configure a reverse proxy in your Nginx virtual host. Here is simple naive example:
         | 
| 286 | 
            +
             | 
| 287 | 
            +
            ```nginx
         | 
| 288 | 
            +
            server {
         | 
| 289 | 
            +
                server_name my-rails-app.com;
         | 
| 290 | 
            +
                listen 443 ssl http2;
         | 
| 291 | 
            +
                listen [::]:443 ssl http2;
         | 
| 292 | 
            +
                location / {
         | 
| 293 | 
            +
                    proxy_pass http://127.0.0.1:8888;
         | 
| 294 | 
            +
                    proxy_redirect off;
         | 
| 295 | 
            +
                    proxy_set_header Connection "upgrade";
         | 
| 296 | 
            +
                    proxy_set_header Host $http_host;
         | 
| 297 | 
            +
                    proxy_set_header Upgrade $http_upgrade;
         | 
| 298 | 
            +
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         | 
| 299 | 
            +
                    proxy_set_header X-Forwarded-Proto https;
         | 
| 300 | 
            +
                    proxy_set_header X-Real-IP $remote_addr;
         | 
| 301 | 
            +
                }
         | 
| 302 | 
            +
            }
         | 
| 303 | 
            +
            ```
         | 
| 304 | 
            +
             | 
| 305 | 
            +
            Then you'll have to start Puma in production daemon mode as follows:
         | 
| 306 | 
            +
             | 
| 307 | 
            +
            ```bash
         | 
| 308 | 
            +
            RAILS_ENV=production bin/rails server -p 8888 --daemon
         | 
| 309 | 
            +
            ```
         | 
| 310 | 
            +
             | 
| 311 | 
            +
            Naturally, there are many downsides (in terms of efficiency, scalability, security, etc) to running your application in production in this manner, so please use the above as an example only.
         | 
| 312 | 
            +
             | 
| 313 | 
            +
             | 
| 311 314 | 
             
            ## Example
         | 
| 312 315 |  | 
| 313 316 | 
             
            The following [example.rb](example/run.rb) with [input.pdf](example/input.pdf) is located in the [example](example) directory. It uses all of the methods that are described above and generates the output files [output.pdf](example/output.pdf) and [output.flat.pdf](example/output.flat.pdf).
         | 
| Binary file | 
| Binary file | 
    
        data/ext/forms-7.2.3.jar
    ADDED
    
    | Binary file | 
    
        data/ext/io-7.2.3.jar
    ADDED
    
    | Binary file | 
| Binary file | 
| Binary file | 
    
        data/fillable-pdf.gemspec
    CHANGED
    
    | @@ -30,7 +30,8 @@ Gem::Specification.new do |spec| | |
| 30 30 | 
             
              spec.add_development_dependency 'rubocop-performance'
         | 
| 31 31 | 
             
              spec.add_development_dependency 'rubocop-rake'
         | 
| 32 32 |  | 
| 33 | 
            -
              spec.add_runtime_dependency 'rjb', '1.6 | 
| 33 | 
            +
              spec.add_runtime_dependency 'rjb', '~> 1.6'
         | 
| 34 | 
            +
              spec.requirements << 'JDK 8.x - 11.x'
         | 
| 34 35 |  | 
| 35 36 | 
             
              spec.metadata = {
         | 
| 36 37 | 
             
                'rubygems_mfa_required' => 'true'
         | 
    
        data/lib/fillable-pdf/itext.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module ITEXT | |
| 8 8 | 
             
                ByteArrayOutputStream = Rjb.import 'com.itextpdf.io.source.ByteArrayOutputStream'
         | 
| 9 9 | 
             
                Canvas = Rjb.import 'com.itextpdf.layout.Canvas'
         | 
| 10 10 | 
             
                Div = Rjb.import 'com.itextpdf.layout.element.Div'
         | 
| 11 | 
            -
                HorizontalAlignment = Rjb.import 'com.itextpdf.layout. | 
| 11 | 
            +
                HorizontalAlignment = Rjb.import 'com.itextpdf.layout.properties.HorizontalAlignment'
         | 
| 12 12 | 
             
                Image = Rjb.import 'com.itextpdf.layout.element.Image'
         | 
| 13 13 | 
             
                ImageDataFactory = Rjb.import 'com.itextpdf.io.image.ImageDataFactory'
         | 
| 14 14 | 
             
                PdfAcroForm = Rjb.import 'com.itextpdf.forms.PdfAcroForm'
         | 
| @@ -19,6 +19,6 @@ module ITEXT | |
| 19 19 | 
             
                PdfReader = Rjb.import 'com.itextpdf.kernel.pdf.PdfReader'
         | 
| 20 20 | 
             
                PdfWriter = Rjb.import 'com.itextpdf.kernel.pdf.PdfWriter'
         | 
| 21 21 | 
             
                Rectangle = Rjb.import 'com.itextpdf.kernel.geom.Rectangle'
         | 
| 22 | 
            -
                VerticalAlignment = Rjb.import 'com.itextpdf.layout. | 
| 22 | 
            +
                VerticalAlignment = Rjb.import 'com.itextpdf.layout.properties.VerticalAlignment'
         | 
| 23 23 | 
             
              end
         | 
| 24 24 | 
             
            end
         | 
    
        data/lib/fillable-pdf/version.rb
    CHANGED
    
    
    
        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)
         | 
| 13 | 
            +
              def initialize(file_path) # rubocop:disable Metrics/MethodLength
         | 
| 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,6 +20,7 @@ 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
         | 
| 23 24 | 
             
                rescue StandardError => e
         | 
| 24 25 | 
             
                  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
         | 
| 25 26 | 
             
                end
         | 
| @@ -144,7 +145,7 @@ class FillablePDF # rubocop:disable Metrics/ClassLength | |
| 144 145 | 
             
              #
         | 
| 145 146 | 
             
              def set_image_base64(key, base64_image_data)
         | 
| 146 147 | 
             
                tmp_file = SecureRandom.uuid
         | 
| 147 | 
            -
                File. | 
| 148 | 
            +
                File.binwrite(tmp_file, Base64.decode64(base64_image_data))
         | 
| 148 149 | 
             
                set_image(key, tmp_file)
         | 
| 149 150 | 
             
              ensure
         | 
| 150 151 | 
             
                FileUtils.rm tmp_file
         | 
    
        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 | 
            +
              version: 0.9.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Vadim Kononov
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2022-07-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -126,16 +126,16 @@ dependencies: | |
| 126 126 | 
             
              name: rjb
         | 
| 127 127 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 128 | 
             
                requirements:
         | 
| 129 | 
            -
                - -  | 
| 129 | 
            +
                - - "~>"
         | 
| 130 130 | 
             
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            -
                    version: 1.6 | 
| 131 | 
            +
                    version: '1.6'
         | 
| 132 132 | 
             
              type: :runtime
         | 
| 133 133 | 
             
              prerelease: false
         | 
| 134 134 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 135 | 
             
                requirements:
         | 
| 136 | 
            -
                - -  | 
| 136 | 
            +
                - - "~>"
         | 
| 137 137 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            -
                    version: 1.6 | 
| 138 | 
            +
                    version: '1.6'
         | 
| 139 139 | 
             
            description: FillablePDF is an extremely simple and lightweight utility that bridges
         | 
| 140 140 | 
             
              iText and Ruby in order to fill out fillable PDF forms or extract field values from
         | 
| 141 141 | 
             
              previously filled out PDF forms.
         | 
| @@ -154,11 +154,12 @@ files: | |
| 154 154 | 
             
            - Rakefile
         | 
| 155 155 | 
             
            - bin/console
         | 
| 156 156 | 
             
            - bin/setup
         | 
| 157 | 
            -
            - ext/ | 
| 158 | 
            -
            - ext/ | 
| 159 | 
            -
            - ext/ | 
| 160 | 
            -
            - ext/ | 
| 161 | 
            -
            - ext/ | 
| 157 | 
            +
            - ext/commons-7.2.3.jar
         | 
| 158 | 
            +
            - ext/font-asian-7.2.3.jar
         | 
| 159 | 
            +
            - ext/forms-7.2.3.jar
         | 
| 160 | 
            +
            - ext/io-7.2.3.jar
         | 
| 161 | 
            +
            - ext/kernel-7.2.3.jar
         | 
| 162 | 
            +
            - ext/layout-7.2.3.jar
         | 
| 162 163 | 
             
            - ext/slf4j-api-1.7.32.jar
         | 
| 163 164 | 
             
            - ext/slf4j-simple-1.7.32.jar
         | 
| 164 165 | 
             
            - fillable-pdf.gemspec
         | 
| @@ -187,8 +188,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 187 188 | 
             
              - - ">="
         | 
| 188 189 | 
             
                - !ruby/object:Gem::Version
         | 
| 189 190 | 
             
                  version: '0'
         | 
| 190 | 
            -
            requirements: | 
| 191 | 
            -
             | 
| 191 | 
            +
            requirements:
         | 
| 192 | 
            +
            - JDK 8.x - 11.x
         | 
| 193 | 
            +
            rubygems_version: 3.3.7
         | 
| 192 194 | 
             
            signing_key:
         | 
| 193 195 | 
             
            specification_version: 4
         | 
| 194 196 | 
             
            summary: Fill out or extract field values from simple fillable PDF forms using iText.
         | 
    
        data/ext/forms-7.1.17.jar
    DELETED
    
    | Binary file | 
    
        data/ext/io-7.1.17.jar
    DELETED
    
    | Binary file | 
    
        data/ext/kernel-7.1.17.jar
    DELETED
    
    | Binary file | 
    
        data/ext/layout-7.1.17.jar
    DELETED
    
    | Binary file |