{"id":24371,"library":"pypdf4","title":"PyPDF4","description":"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.","status":"active","version":"1.27.0","language":"python","source_language":"en","source_url":"http://claird.github.com/PyPDF4","tags":["pdf","pdf-toolkit","pdf-manipulation"],"install":[{"cmd":"pip install pypdf4","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"PyPDF4 is a separate fork; do not mix with PyPDF2.","wrong":"import PyPDF2\nfrom PyPDF4 import PdfFileReader","symbol":"PdfFileReader","correct":"from PyPDF4 import PdfFileReader"}],"quickstart":{"code":"from PyPDF4 import PdfFileReader, PdfFileWriter\n\n# Read a PDF\nreader = PdfFileReader(open('example.pdf', 'rb'))\nprint(f\"Number of pages: {reader.numPages}\")\n\n# Write a PDF\nwriter = PdfFileWriter()\nwriter.addPage(reader.getPage(0))\nwith open('output.pdf', 'wb') as f:\n    writer.write(f)","lang":"python","description":"Basic example: read a PDF and write its first page to a new file."},"warnings":[{"fix":"Uninstall PyPDF2 if you intend to use PyPDF4, or vice versa. Use only one library.","message":"PyPDF4 is not compatible with PyPDF2. Do not install both; they use similar imports and can conflict.","severity":"breaking","affected_versions":"all"},{"fix":"Transition to the modern API: pages = reader.pages; len(pages); pages[0].","message":"The numPages and getPage() methods are deprecated in favor of len(reader.pages) and reader.pages[index]. Future versions may remove the old API.","severity":"deprecated","affected_versions":">=1.27.0"},{"fix":"Refer to the documentation for each method's exact name; future versions may standardize to snake_case.","message":"The library uses a mix of camelCase and snake_case method names (e.g., numPages vs getPage).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: pip install pypdf4","cause":"PyPDF4 is not installed or you have PyPDF2 installed instead.","error":"ImportError: cannot import name 'PdfFileReader' from 'PyPDF4'"},{"fix":"Use: reader = PdfFileReader(stream)","cause":"Using PyPDF4's PdfFileReader as a function instead of a class instantiation.","error":"TypeError: 'PdfFileReader' object is not callable"},{"fix":"Use PdfFileWriter and its appendPagesFromReader method.","cause":"PyPDF4 removed PdfFileMerger in favor of merging via PdfFileWriter.","error":"AttributeError: module 'PyPDF4' has no attribute 'PdfFileMerger'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}