Read pdf files as binary.
- Legacy-Id: 16510
This commit is contained in:
parent
db47cb6b0f
commit
618d6021b0
|
@ -10,11 +10,11 @@ import re
|
|||
def pdf_pages(filename):
|
||||
"""Return number of pages in PDF."""
|
||||
try:
|
||||
infile = io.open(filename, "r")
|
||||
infile = io.open(filename, "rb")
|
||||
except IOError:
|
||||
return 0
|
||||
for line in infile:
|
||||
m = re.match(r'\] /Count ([0-9]+)',line)
|
||||
m = re.match(br'\] /Count ([0-9]+)',line)
|
||||
if m:
|
||||
return int(m.group(1))
|
||||
return 0
|
||||
|
|
Loading…
Reference in a new issue