lib/docsplit/transparent_pdfs.rb in burisu-docsplit-0.7.5 vs lib/docsplit/transparent_pdfs.rb in burisu-docsplit-0.7.6

- old
+ new

@@ -7,10 +7,10 @@ # 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, &:readline) =~ /\A\%PDF-\d+(\.\d+)?$/ + 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')