{"id":2186,"library":"pdfrw","title":"pdfrw Library","description":"pdfrw is a pure Python library for reading and writing PDF files. It's designed for efficiency, offering capabilities for operations such as subsetting, merging, rotating, and modifying PDF metadata. The current version, 0.4, primarily focused on enhancing Python 3 compatibility and proper Unicode support. While still functional, its release cadence has been sporadic, and some sources suggest development has ceased.","status":"maintenance","version":"0.4","language":"en","source_language":"en","source_url":"https://github.com/pmaupin/pdfrw","tags":["pdf","document processing","reader","writer","pure-python"],"install":[{"cmd":"pip install pdfrw","lang":"bash","label":"Install pdfrw"}],"dependencies":[],"imports":[{"symbol":"PdfReader","correct":"from pdfrw import PdfReader"},{"symbol":"PdfWriter","correct":"from pdfrw import PdfWriter"},{"symbol":"PageMerge","correct":"from pdfrw import PageMerge"},{"note":"While 'from pdfrw import *' was fixed in v0.3 to work properly, explicit imports are generally recommended for clarity and avoiding namespace pollution.","symbol":"*","correct":"from pdfrw import *"}],"quickstart":{"code":"from pdfrw import PdfReader, PdfWriter, PageMerge\n\n# Create a dummy input PDF for the example\n# In a real scenario, 'input.pdf' would already exist.\nwriter = PdfWriter()\nwriter.addpages([PageMerge().add_text(\"Hello World\").render()])\nwriter.write(\"input.pdf\")\n\n# Read an existing PDF\nreader = PdfReader(\"input.pdf\")\n\n# Create a new PdfWriter object\nwriter = PdfWriter()\n\n# Add all pages from the reader to the writer\nwriter.addpages(reader.pages)\n\n# Write the content to a new PDF file (e.g., creating a copy)\nwriter.write(\"output_copy.pdf\")\n\nprint(\"PDF 'input.pdf' read and copied to 'output_copy.pdf'\")\n","lang":"python","description":"This quickstart demonstrates how to read an existing PDF file and write its contents to a new PDF file, effectively creating a copy. It also includes a basic step to create a dummy `input.pdf` for a runnable example."},"warnings":[{"fix":"Use external tools (e.g., `pdftk`) to uncompress or decrypt PDFs before feeding them to pdfrw, or use another Python PDF library with more comprehensive compression/encryption support.","message":"pdfrw has limited support for compression and no built-in support for encryption in PDF files. For such files, users might need to pre-process them with external tools like `pdftk` to uncompress or decrypt before `pdfrw` can process them reliably.","severity":"gotcha","affected_versions":"<=0.4"},{"fix":"Evaluate whether pdfrw meets your long-term project needs given the maintenance status. Consider alternative libraries for actively developed features or if encountering unresolvable issues.","message":"The library's development seems to have ceased, with the last release (v0.4) in 2017. While it remains functional for many tasks, users should be aware of the lack of ongoing maintenance and potential for unaddressed bugs or compatibility issues with newer Python versions or PDF specifications. Some sources explicitly state it is 'not maintained anymore'.","severity":"deprecated","affected_versions":"0.4 and potentially future Python versions"},{"fix":"Ensure you are using pdfrw v0.2 or later for Python 3 compatibility. Review and update code for Python 2-to-3 string and byte handling if migrating.","message":"Initial versions of pdfrw (prior to v0.2) only supported Python 2. Support for Python 3 was introduced in v0.2. Older Python 2 codebases might require adaptation for Python 3 environments, particularly regarding string handling.","severity":"breaking","affected_versions":"<0.2 (Python 2 only)"},{"fix":"Upgrade to pdfrw v0.4 for improved Unicode handling. If using older versions, be cautious with non-ASCII text and consider pre-processing or alternative methods for text injection.","message":"Proper Unicode support for text strings in PDFs was added in v0.4. Earlier versions might exhibit issues when handling or embedding non-ASCII or international characters, which could lead to corrupted text or errors.","severity":"gotcha","affected_versions":"<0.4"},{"fix":"Be aware that bookmarks may not be preserved during operations like page merging or concatenation. If bookmark preservation is critical, consider using `pdftk` or `PyPDF2` (which generally supports more features) in conjunction with pdfrw or as an alternative.","message":"When merging or manipulating PDFs, pdfrw might not preserve certain PDF features like bookmarks (outlines) as it often reconstructs page display information. This can result in a loss of navigation elements in the output PDF.","severity":"gotcha","affected_versions":"<=0.4"},{"fix":"Upgrade to pdfrw v0.3 or later to benefit from critical `PageMerge` bug fixes, ensuring more stable and predictable merging operations.","message":"Version 0.3 included fixes for several `PageMerge` bugs, specifically related to multiple program runs and state save/restore. Prior to these fixes, `PageMerge` operations could be unreliable or lead to unexpected behavior.","severity":"gotcha","affected_versions":"<0.3"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}