count the number of pages in pdf file
Question:
I have a problem when I use this code to count the number of pages in pdf file :
if j[i].rstrip() == "Page" or j[i].rstrip() == "page":
rxcountpages = re.compile(r"/Types*/Page([^s]|$)", re.MULTILINE|re.DOTALL)
data = file("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb")
print len(rxcountpages.findall(data))
the error is:
Traceback (most recent call last):
File “pdf_scanner.py”, line 89, in
main()
File “pdf_scanner.py”, line 72, in main
print len(rxcountpages.findall(data))
TypeError: expected string or buffer
can an one help me with it?
Answers:
you have to read the contents of the file:
data = open("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb").read()
I have a problem when I use this code to count the number of pages in pdf file :
if j[i].rstrip() == "Page" or j[i].rstrip() == "page":
rxcountpages = re.compile(r"/Types*/Page([^s]|$)", re.MULTILINE|re.DOTALL)
data = file("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb")
print len(rxcountpages.findall(data))
the error is:
Traceback (most recent call last):
File “pdf_scanner.py”, line 89, in
main()
File “pdf_scanner.py”, line 72, in main
print len(rxcountpages.findall(data))
TypeError: expected string or buffer
can an one help me with it?
you have to read the contents of the file:
data = open("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb").read()