Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Errors with PyPdf
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="flebber, post: 4135515"] okay thanks I thought that when I set content here def getPDFContent(path): content = "C:\Components-of-Dot-NET.pdf" that i was defining where it is. but yeah I updated script to below and it works. That is the contents are displayed to the interpreter. How do I output to a .txt file? import pyPdf def getPDFContent(path): content = "C:\Components-of-Dot-NET.pdf" # Load PDF into pyPDF pdf = pyPdf.PdfFileReader(file(path, "rb")) # Iterate pages for i in range(0, pdf.getNumPages()): # Extract text from page and add to content content += pdf.getPage(i).extractText() + "\n" # Collapse whitespace content = " ".join(content.replace(u"\xa0", " ").strip().split()) return content print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii", "ignore") [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Errors with PyPdf
Top