Guest User

Untitled

a guest
Jul 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. x = myurl.pdf
  2. if ".pdf" in x:
  3. remoteFile = urlopen(Request(x, headers={"User-Agent": "Magic-Browser"})).read()
  4. memoryFile = StringIO(remoteFile)
  5. pdfFile = PyPDF2.PdfFileReader(memoryFile, strict=False)
  6. num_pages = pdfFile.numPages
  7. count = 0
  8. text = ""
  9. while count < num_pages:
  10. pageObj = pdfFile.getPage(count)
  11. count += 1
  12. text += pageObj.extractText()
  13.  
  14. Traceback (most recent call last):
  15. File "errortest.py", line 30, in <module>
  16. text += pageObj.extractText()
  17. File "/anaconda2/lib/python2.7/site-packages/PyPDF2/pdf.py", line 2595, in extractText
  18. content = ContentStream(content, self.pdf)
  19. File "/anaconda2/lib/python2.7/site-packages/PyPDF2/pdf.py", line 2674, in __init__
  20. self.__parseContentStream(stream)
  21. File "/anaconda2/lib/python2.7/site-packages/PyPDF2/pdf.py", line 2706, in __parseContentStream
  22. operands.append(readObject(stream, None))
  23. File "/anaconda2/lib/python2.7/site-packages/PyPDF2/generic.py", line 98, in readObject
  24. return NumberObject.readFromStream(stream)
  25. File "/anaconda2/lib/python2.7/site-packages/PyPDF2/generic.py", line 271, in readFromStream
  26. return FloatObject(num)
  27. File "/anaconda2/lib/python2.7/site-packages/PyPDF2/generic.py", line 231, in __new__
  28. return decimal.Decimal.__new__(cls, str(value))
  29. File "/anaconda2/lib/python2.7/decimal.py", line 547, in __new__
  30. "Invalid literal for Decimal: %r" % value)
  31. File "/anaconda2/lib/python2.7/decimal.py", line 3872, in _raise_error
  32. raise error(explanation)
  33. decimal.InvalidOperation: Invalid literal for Decimal: '99.-72'
Add Comment
Please, Sign In to add comment