Sha256: 13fabe77b8697053b9083a7de00c39d53d9e3a3fff43f1f5736f35cb34d0748e

Contents?: true

Size: 750 Bytes

Versions: 53

Compression:

Stored size: 750 Bytes

Contents

require 'ndr_support/safe_file'

module NdrImport
  module Helpers
    module File
      # This mixin adds PDF functionality to unified importers. It provides a file reader method.
      module Pdf
        private

        def read_pdf_file(path)
          require 'pdf-reader'
          lines = []
          pagenum = 0
          begin
            reader = PDF::Reader.new(SafeFile.safepath_to_string(path))

            reader.pages.each do |page|
              lines.concat page.text.split("\n")
              pagenum += 1
            end
          rescue => e
            raise("Invalid format on page #{pagenum + 1} of #{SafeFile.basename(path)} [#{e.class}: #{e.message}]")
          end
          lines
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
ndr_import-4.1.1 lib/ndr_import/helpers/file/pdf.rb
ndr_import-4.1.0 lib/ndr_import/helpers/file/pdf.rb
ndr_import-4.0.1 lib/ndr_import/helpers/file/pdf.rb
ndr_import-4.0.0 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.6 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.5 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.4 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.3 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.2 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.1 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.1.0 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.0.1 lib/ndr_import/helpers/file/pdf.rb
ndr_import-3.0.0 lib/ndr_import/helpers/file/pdf.rb