Registry / serialization / pypdf4

pypdf4

JSON →
library1.27.0pypypi✓ verified 86d ago

PyPDF4 is a pure-Python PDF toolkit capable of splitting, merging, cropping, and transforming PDF files. Current version is 1.27.0. The library is in maintenance mode with slow updates.

pip install pypdf4
INSTALL
IMPORT
SIG · PYPDF4
P
pypdf4
serializationpythonv1.27.0
Install
2.4s avg
Import
30ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.27.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.032s · 19.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.028s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PdfFileReader
from PyPDF4 import PdfFileReader
import PyPDF2 from PyPDF4 import PdfFileReader
PyPDF4 is a separate fork; do not mix with PyPDF2.

Basic example: read a PDF and write its first page to a new file.

from PyPDF4 import PdfFileReader, PdfFileWriter # Read a PDF reader = PdfFileReader(open('example.pdf', 'rb')) print(f"Number of pages: {reader.numPages}") # Write a PDF writer = PdfFileWriter() writer.addPage(reader.getPage(0)) with open('output.pdf', 'wb') as f: writer.write(f)
Debug
Known issues
breakingPyPDF4 is not compatible with PyPDF2. Do not install both; they use similar imports and can conflict.
fix
Uninstall PyPDF2 if you intend to use PyPDF4, or vice versa. Use only one library.
affects: all
deprecatedThe numPages and getPage() methods are deprecated in favor of len(reader.pages) and reader.pages[index]. Future versions may remove the old API.
fix
Transition to the modern API: pages = reader.pages; len(pages); pages[0].
affects: >=1.27.0
gotchaThe library uses a mix of camelCase and snake_case method names (e.g., numPages vs getPage).
fix
Refer to the documentation for each method's exact name; future versions may standardize to snake_case.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'PdfFileReader' from 'PyPDF4'
PyPDF4 is not installed or you have PyPDF2 installed instead.
fix
Run: pip install pypdf4
TypeError: 'PdfFileReader' object is not callable
Using PyPDF4's PdfFileReader as a function instead of a class instantiation.
fix
Use: reader = PdfFileReader(stream)
AttributeError: module 'PyPDF4' has no attribute 'PdfFileMerger'
PyPDF4 removed PdfFileMerger in favor of merging via PdfFileWriter.
fix
Use PdfFileWriter and its appendPagesFromReader method.
Upgrade
Version history
1.27.0latest on PyPI · released Aug 7, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
pypdf4 — pip install pypdf4 · libregistry