Method: Docsplit::TransparentPDFs#ensure_pdfs
- Defined in:
- lib/docsplit/transparent_pdfs.rb
#ensure_pdfs(docs) ⇒ Object
Temporarily convert any non-PDF documents to PDFs before running them through further extraction.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/docsplit/transparent_pdfs.rb', line 9 def ensure_pdfs(docs) [docs].flatten.map do |doc| if is_pdf?(doc) doc else tempdir = File.join(Dir.tmpdir, 'docsplit') extract_pdf([doc], {:output => tempdir}) File.join(tempdir, File.basename(doc, File.extname(doc)) + '.pdf') end end end |