Maintained Alternatives to Pypdf2
I'm Using the Pypdf2 Library for Extracting Text, Images, Page Width and Heights, Annotations, and Other Attributes from Pdf Documents. However, the Library...
I'm using the PyPDF2 library for extracting text, images, page width and heights, annotations, and other attributes from pdf documents. However, the library has many bugs and issues and seems not to be maintained for a long time already. (edit: PyPDF2 is maintained again)
- Is there a more vivid fork that is being maintained and developed?
- Is there a good alternative?
From what I know, reportlab is more suitable for creating brand new pdf's (or maybe I'm just not experienced enough with reportlab).
4 Answers
Update: pypdf (pypi) is maintained again - and I am the maintainer (of pypdf and PyPDF2) :-) I've just released a new version with several bugfixes.
Looking at the top PyPI packages, PyPDF2 is also the most used one (and pypdf==3.1.0 is almost the same as PyPDF2==3.0.0, the community just needs a bit of time to switch to pypdf)
Three potential alternatives which are maintained (just like pypdf):
pymupdf: uses mupdf (only free for open source due to mypdf license)pikepdf: Uses qpdfpdfminer.six: A pure Python project.
I would not use:
PyMuPDF is a Python binding for MuPDF – a lightweight PDF and XPS viewer. Because MuPDF supports not only PDF but also XPS, OpenXPS, CBZ, CBR, FB2, and EPUB formats, so does PyMuPDF. PyMuPDF is hosted on GitHub. We also are registered on PyPI.
Its performance stats are also very promising. Following are three sections that deal with different aspects of performance:
- document parsing
- text extraction
- image rendering
pdfplumber can also be considered to extract text, images and other information from PDF file. It works best with the table in compare to other library. Extracting the information of the table to pandas DataFrame is also easy. extract_text() also has a layout=True parameter to get the almost-exact layout of the text. It currently does not have support for forms. github link to the repo
disclaimer I am the author of borb
You can use borb to:
- extract text
- extract text filtered by font
- extract text filtered by color
- extract text filtered by bounding box
- extract text by regular expression
- extract annotations
- extract images (as a PIL Image)
borb offers both a high-level view of a PDF, as well as a low-level representation. The low-level representation models a PDF as a JSON-like object. By doing so, you can just navigate through the document and obtain whatever properties you need (if there isn't a high-level method for it yet).
You can install borb by using pip:
pip install borb
You can also just download its source code on GitHub.
borb also has a giant repository of examples on GitHub. You'll find everything I mentioned here (and much more) in that repository.