Sha256: 96f981209127cd9cd7431fb395e29268ab79b7e406dd9e8afd9adc6e27f7282c

Contents?: true

Size: 696 Bytes

Versions: 18

Compression:

Stored size: 696 Bytes

Contents

module Docsplit

  # Include a method to transparently convert non-PDF arguments to temporary
  # PDFs. Allows us to pretend to natively support docs, rtf, ppt, and so on.
  module TransparentPDFs

    # Temporarily convert any non-PDF documents to PDFs before running them
    # through further extraction.
    def ensure_pdfs(docs)
      [docs].flatten.map do |doc|
        ext = File.extname(doc)
        if ext.downcase == '.pdf'
          doc
        else
          tempdir = File.join(Dir.tmpdir, 'docsplit')
          extract_pdf([doc], {:output => tempdir})
          File.join(tempdir, File.basename(doc, ext) + '.pdf')
        end
      end
    end

  end

  extend TransparentPDFs

end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
docsplit-0.7.4 lib/docsplit/transparent_pdfs.rb
docsplit-0.7.3 lib/docsplit/transparent_pdfs.rb
docsplit-0.7.2 lib/docsplit/transparent_pdfs.rb
docsplit-0.7.1 lib/docsplit/transparent_pdfs.rb
mateusmaso-docsplit-0.6.4 lib/docsplit/transparent_pdfs.rb
docsplit-0.6.4 lib/docsplit/transparent_pdfs.rb
docsplit-0.6.3 lib/docsplit/transparent_pdfs.rb
docsplit-0.6.2 lib/docsplit/transparent_pdfs.rb
docsplit-0.6.1 lib/docsplit/transparent_pdfs.rb
docsplit-0.6.0 lib/docsplit/transparent_pdfs.rb
talentbox-docsplit-0.5.2 lib/docsplit/transparent_pdfs.rb
docsplit-0.5.2 lib/docsplit/transparent_pdfs.rb
docsplit-0.5.1 lib/docsplit/transparent_pdfs.rb
docsplit-0.5.0 lib/docsplit/transparent_pdfs.rb
docsplit-0.4.1 lib/docsplit/transparent_pdfs.rb
docsplit-0.4.0 lib/docsplit/transparent_pdfs.rb
docsplit-0.3.4 lib/docsplit/transparent_pdfs.rb
docsplit-0.3.3 lib/docsplit/transparent_pdfs.rb