I need to parse a remote pdf file. With PyPDF2, it can be done by PdfReader(f), where f=urllib.request.urlopen("some-url").read() . f cannot be used by the PdfReader, and it seems that f has to be decoded. What argument should be used in decode(), or some other method has to be used.
parsing a remote pdf file with Python3 & PyPDF2
2.7k Views Asked by Tom Liu At
2
There are 2 best solutions below
2
celsowm
On
It is possible to decode using BytesIO:
import urllib, PyPDF2
from io import BytesIO
f = urllib.request.urlopen("https://mypdf.pdf").read()
pdf_bytes = BytesIO(f)
pdf_reader = PyPDF2.PdfFileReader(pdf_bytes)
Related Questions in PYTHON-3.X
- Update a text file with ( new words+ \n ) after the words is appended into a list
- Kivy - Create new widget and set its position and size
- TypeError: encoding or errors without a string argument
- How to print varible name in python
- PyQt, Python 3: Lambda slot assigning signal argument to a variable?
- How to write data to stdin of the first process in a Python shell pipeline?
- pygame.draw.circle, still draws a square
- Duplicate Frames Created When Calling a Function in a Tkinter Application
- Python TypeError: can only concatenate tuple (not "int") to tuple
- recursively editing member variable: All instances have same value
- missing 1 required positional argument: 'key'
- How do I fix this sorting error?
- Dictionary values missing
- Why does opening a file in two different encodings work as expected?
- Binary bit flip generator in python
Related Questions in PDF
- Itext get special letters from pdf
- Carrierwave file upload with different file types
- Get text from a section of a pdf page with IcePdf
- itext pdf to image convert
- PDF to Text extractor in nodejs without OS dependencies
- PDF to ByteArray Conversion
- Opening PDF file in SWT Browser - XulRunner default viewer
- Generate TCPDF output to a shared drive folder
- Combine base and ggplot graphics in R figure window in different pages
- Updating a PDF Barcode Field in iOS and Android Device
- Prevent PDFsharp from saving an image file?
- Adding attachment links between lines in itext for pdf
- Crop Pdf from each edge using itextshap
- How to create a PDF with iText+XMLWorker from servlet using custom font?
- how to create a pdf editor for grails
Related Questions in DECODE
- Decode Json Object Php
- Python 3.4 decode bytes
- How to use Oracle's decode function in where clause
- encode, decode base64 image stream delphi
- Populating data from a binary stream using byte array in java
- Decode function for MySQL
- saving base64 decoded string into a zip file
- Infinite loop when decoding a message received from a Socket in Python 3.3.5
- Extracting/Decoding name from USB Credit Card reader
- How to decode a 9 digit integer to some random 4 digit word
- What is the impact of different JPEG's type on different JPEG decoding sub-process.?
- I can't decode data from HTML page in swift
- Encoding NSData into string containing only numbers and decoding back
- How to decode Json Format for the proto files using Protobuf.js?
- Convert Base64 image to file path image in iOS programming
Related Questions in PYPDF
- Start first PDF page a certain distance from top then start at the top on every page after that?
- parsing a remote pdf file with Python3 & PyPDF2
- PyPDF2 - merging pages from two different PDF files is not working
- Regular Expression with parenthesis in a string from PyPDF2 and DataFrame with positive and negative numbers
- text printed twice on the same page
- Reading line in PDF using python
- PDF File Security Settings
- Generate flattened PDF with Python
- pyPDF2 merging error coercing to Unicode
- pyPdf IndirectObject in /Rotate
- PyPDF2 write doesn't work on some PDF files (Python 3.5.1)
- PyPDF2 giving me an invalid argument error
- How to get PDF file metadata 'Page Size' using Python?
- Appending pdf files based multilpe values in a dictionary key (or csv) results in too many pages
- How to define a list in python tkinter mainloop without changing it's value
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You need to use:
Add these lines after above line:
and then read using PdfReader as:
Also, refer: Opening pdf urls with pyPdf