Metadata-Version: 2.4
Name: pdfreader
Version: 0.2.0
Summary: Read PDF structure and extract text, images, forms, annotations, metadata, and other PDF objects
Home-page: https://github.com/maxpmaxp/pdfreader
Author: Maksym Polshcha
Author-email: maxp@sterch.net
Maintainer: Maksym Polshcha
Maintainer-email: maxp@sterch.net
License: MIT Licence
Project-URL: Documentation, https://pdfreader.readthedocs.io/en/latest/
Project-URL: Source, https://github.com/maxpmaxp/pdfreader
Project-URL: Issues, https://github.com/maxpmaxp/pdfreader/issues
Keywords: pdf,pdf reader,pdf parser,pdf extraction,text extraction,pdf forms,pdf images,fonts,cmap,unicode,glyphs
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: bitarray<3,>=2.9.2; python_version < "3.7"
Requires-Dist: bitarray>=2.9.2; python_version >= "3.7"
Requires-Dist: pillow>=7.1.0
Requires-Dist: pycryptodome>=3.19.1
Requires-Dist: python-dateutil>=2.8.1
Requires-Dist: importlib_resources<6,>=5.4; python_version < "3.9"
Provides-Extra: test
Requires-Dist: coverage[toml]<6,>=5.5; python_version < "3.7" and extra == "test"
Requires-Dist: coverage[toml]>=7.0; python_version >= "3.7" and extra == "test"
Requires-Dist: flake8<4,>=3.9; python_version < "3.8" and extra == "test"
Requires-Dist: flake8>=7.0; python_version >= "3.8" and extra == "test"
Requires-Dist: importlib-metadata<5; python_version < "3.8" and extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx<5,>=4.5; python_version < "3.8" and extra == "docs"
Requires-Dist: sphinx>=7.0; python_version >= "3.8" and extra == "docs"
Requires-Dist: setuptools<81; extra == "docs"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

=========
pdfreader
=========
:Info: See the `pdfreader documentation <https://pdfreader.readthedocs.io/en/latest/>`_.
:Author & Maintainer: Maksym Polshcha <maxp@sterch.net>

**pdfreader** is a read-only Python PDF parser that reads PDF structure directly
and extracts text, images, forms, fonts, CMaps, annotations, metadata, and other
document objects. It does not require an external PDF engine or rasterize pages
to expose their contents.

Use pdfreader when a Python application needs read-only access to PDF content,
low-level PDF objects, or predictable memory controls for large documents.
Text extraction preserves the source content-stream order and offers opt-in
diagnostics and custom mappings for font codes that a PDF does not map reliably
to Unicode.

The library provides two complementary interfaces:

* ``PDFDocument`` exposes the document catalog, page tree, indirect objects,
  streams, and metadata.
* ``SimplePDFViewer`` interprets page content and writes decoded data to a
  ``SimpleCanvas``.

What pdfreader provides
=======================

* **Extract PDF text and page content:** decode string fragments, text-showing
  groups, images, form XObjects, annotations, and inline images through
  ``SimpleCanvas``.
* **Inspect PDF structure:** access the document catalog, page tree, indirect
  objects, streams, fonts, CMaps, and metadata with ``PDFDocument``.
* **Process large PDFs:** resolve objects lazily, reuse page and font indexes,
  and opt into bounded caches when memory retention matters.
* **Diagnose custom fonts:** collect unresolved glyph codes, supply a
  document-local glyph resolver, or choose an explicit unknown-glyph policy.
* **Read protected PDFs:** open password-protected documents that use a
  supported PDF standard security handler.
* **Save extracted images:** convert supported PDF image objects to Pillow
  images.

pdfreader does not create, edit, split, merge, rasterize, or convert PDF files.
Extracted text follows content-stream order and does not automatically
reconstruct visual lines, columns, or tables.

PDF version compatibility
=========================

pdfreader targets the PDF 1.7 data model and recognizes standard
``%PDF-2.0`` file headers. Header recognition does not imply complete support
for every feature introduced by ISO 32000-2. See the
`PDF compatibility guide <https://pdfreader.readthedocs.io/en/latest/pdf-compatibility.html>`_
for the tested boundary and reporting guidance.

Installation
============

pdfreader is tested on Python 3.6 through Python 3.14. Install it from PyPI with
pip::

  python -m pip install pdfreader

Extract text from a PDF in Python
=================================

Extract decoded string fragments from the first page::

  from pdfreader import SimplePDFViewer

  with open("document.pdf", "rb") as stream:
      viewer = SimplePDFViewer(stream)
      viewer.navigate(1)
      viewer.render()
      text = "".join(viewer.canvas.strings)

PDF text is stored as font-specific character codes and drawing operators, not
as ready-made paragraphs. For PDFs with missing Unicode mappings, use the
`unknown-glyph diagnostics and custom mapping guide
<https://pdfreader.readthedocs.io/en/latest/text-extraction.html>`_. For
sequential scans or long-running services, see the `large-PDF performance and
bounded-cache guide
<https://pdfreader.readthedocs.io/en/latest/large-files.html>`_.

Documentation
=============

* `Install or upgrade pdfreader <https://pdfreader.readthedocs.io/en/latest/installation.html>`_
* `Follow the tutorial <https://pdfreader.readthedocs.io/en/latest/tutorial.html>`_
* `Improve text extraction and diagnose unknown glyphs <https://pdfreader.readthedocs.io/en/latest/text-extraction.html>`_
* `Check PDF version compatibility <https://pdfreader.readthedocs.io/en/latest/pdf-compatibility.html>`_
* `Configure bounded caches for large files <https://pdfreader.readthedocs.io/en/latest/large-files.html>`_
* `Choose PDFDocument or SimplePDFViewer <https://pdfreader.readthedocs.io/en/latest/examples/document_vs_viewer.html>`_
* `Browse task-based examples <https://pdfreader.readthedocs.io/en/latest/examples/index.html>`_
* `Read the API reference <https://pdfreader.readthedocs.io/en/latest/api/index.html>`_

Support and source
==================

Use `GitHub issues <https://github.com/maxpmaxp/pdfreader/issues>`_ for bug
reports, questions, and feature requests. The latest source is available in the
`GitHub repository <https://github.com/maxpmaxp/pdfreader>`_.

References
==========

* `PDF 1.7 specification <https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf>`_
* `Adobe CMap and CIDFont specification <https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5014.CIDFont_Spec.pdf>`_
* `Adobe CMap resources <https://github.com/adobe-type-tools/cmap-resources>`_
