Sha256: 6ef08b04d5ffcdcdcccbf475197e4f8d3b907c3b8c35d384a7a1dd2679a89198
Contents?: true
Size: 759 Bytes
Versions: 1
Compression:
Stored size: 759 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' || File.open(doc, "rb", &:readline) =~ /\A\%PDF-\d+(\.\d+)?$/ 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
burisu-docsplit-0.7.6 | lib/docsplit/transparent_pdfs.rb |