Skip to content
Advertisement

Tag: pypdf

Convert PDF page to image with pyPDF2 and BytesIO

I have a function that gets a page from a PDF file via pyPdf2 and should convert the first page to a png (or jpg) with Pillow (PIL Fork) That results in an error: OSError: cannot identify image file <_io.BytesIO object at 0x0000023440F3A8E0> I found some threads with a similar issue, (PIL open() method not working with BytesIO) but I

How to install PyPdf2 in PyCharm (Windows-64 bits)

I want to install PyPdf2 in PyCharm for Windows (64 bits) I have tried to go to SettingsProjectProject Interpreter, Then pressing the “+” sign, but It did not found PyPdf2. I already Installed it to the normal python2.7 by going to the extracted path of PyPdf2 then I run (python.exe setup.py install) I tried to install it to anaconda by

Error in the coding of the characters in reading a PDF

I need to read this PDF. I am using the following code: However, the encoding is incorrect, it prints: But I expected How to solve it? I’m using Python 3 Answer The PyPDF2 extractTest method returns UniCode. So you many need to just explicitly encode it. For example, explicitly encoding the Unicode into UTF-8. You’re on Python 3, so you

Why does pyPdf2.PdfFileReader() require a file object as an input?

csv.reader() doesn’t require a file object, nor does open(). Does pyPdf2.PdfFileReader() require a file object because of the complexity of the PDF format, or is there some other reason? Answer It’s just a matter of how the library was written. csv.reader allows any iterable that returns strings (which includes files). open is opening the file, so of course it doesn’t

Inexpensive ways to add seek to a filetype object

PdfFileReader reads the content from a pdf file to create an object. I am querying the pdf from a cdn via urllib.urlopen(), this provides me a file like object, which has no seek. PdfFileReader, however uses seek. What is the simple way to create a PdfFileReader object from a pdf downloaded via url. Now, what can I do to avoid

Cropping pages of a .pdf file

I was wondering if anyone had any experience in working programmatically with .pdf files. I have a .pdf file and I need to crop every page down to a certain size. After a quick Google search I found the pyPdf library for python but my experiments with it failed. When I changed the cropBox and trimBox attributes on a page

Advertisement