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"/Type\s*/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?

Was it helpful?

Solution

you have to read the contents of the file:

data = open("/home/suleiman/Desktop/CVE-2011-2462_36EE5F9C51316E060657AA86D48670E8","rb").read()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top