Skip to content

Commit cac1e39

Browse files
committed
Merge pull request documentcloud#102 from tmaier/issue-98
Check if file is PDF by magic number. Closes documentcloud#98
2 parents 9172e30 + 929a426 commit cac1e39

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/docsplit/transparent_pdfs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module TransparentPDFs
99
def ensure_pdfs(docs)
1010
[docs].flatten.map do |doc|
1111
ext = File.extname(doc)
12-
if ext.downcase == '.pdf'
12+
if ext.downcase == '.pdf' || File.open(doc, &:readline) =~ /\A\%PDF-\d+(\.\d+)?$/
1313
doc
1414
else
1515
tempdir = File.join(Dir.tmpdir, 'docsplit')
@@ -23,4 +23,4 @@ def ensure_pdfs(docs)
2323

2424
extend TransparentPDFs
2525

26-
end
26+
end

0 commit comments

Comments
 (0)