{"id":918,"library":"pdfminer-six","title":"PDFMiner.six","description":"PDFMiner.six is a community-maintained fork of the original PDFMiner, a powerful Python library for parsing and analyzing PDF documents. It focuses on extracting text data, layout information, and other elements like images, and supports various PDF specifications, CJK languages, and encryption. The library is actively maintained, with frequent releases addressing bug fixes, new features, and security enhancements.","status":"active","version":"20260107","language":"python","source_language":"en","source_url":"https://github.com/pdfminer/pdfminer.six","tags":["pdf","parser","text extraction","document analysis","layout analysis"],"install":[{"cmd":"pip install pdfminer.six","lang":"bash","label":"Basic Installation"},{"cmd":"pip install 'pdfminer.six[image]'","lang":"bash","label":"With image extraction support"}],"dependencies":[{"reason":"Required for character set detection.","package":"charset-normalizer","optional":false},{"reason":"Required for handling encrypted PDFs.","package":"cryptography","optional":false},{"reason":"Optional, required for image extraction functionality when installing with the `[image]` extra.","package":"Pillow","optional":true}],"imports":[{"note":"This is the recommended high-level API for simple text extraction.","symbol":"extract_text","correct":"from pdfminer.high_level import extract_text"},{"note":"These are components of the composable (lower-level) API for more granular control over PDF processing.","symbol":"PDFParser, PDFDocument, PDFResourceManager, PDFPageInterpreter, TextConverter, LAParams","correct":"from pdfminer.pdfparser import PDFParser\nfrom pdfminer.pdfdocument import PDFDocument\nfrom pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter\nfrom pdfminer.converter import TextConverter\nfrom pdfminer.layout import LAParams\nfrom pdfminer.pdfpage import PDFPage"}],"quickstart":{"code":"import io\nfrom pdfminer.high_level import extract_text\n\n# For demonstration, let's create a dummy PDF file path.\n# In a real scenario, this would be the path to your .pdf file.\ndummy_pdf_path = \"example.pdf\"\n\n# Create a dummy PDF file for the example to run without error\n# In a real application, replace this with actual PDF file handling.\ntry:\n    with open(dummy_pdf_path, 'wb') as f:\n        f.write(b'%PDF-1.4\\n1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj 2 0 obj<</Type/Pages/Count 1/Kids[3 0 R]>>endobj 3 0 obj<</Type/Page/Parent 2 0 R/MediaBox[0 0 612 792]/Contents 4 0 R>>endobj 4 0 obj<</Length 41>>stream\\nBT /F1 24 Tf 100 700 Td (Hello, PDFMiner.six!) Tj ET\\nendstream\\nxref\\n0 5\\n0000000000 65535 f\\n0000000009 00000 n\\n0000000056 00000 n\\n0000000114 00000 n\\n0000000213 00000 n\\ntrailer<</Size 5/Root 1 0 R>>startxref\\n296\\n%%EOF')\n    \n    # Extract text from the PDF\n    text = extract_text(dummy_pdf_path)\n    print(\"Extracted Text:\")\n    print(text)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up the dummy PDF file\n    import os\n    if os.path.exists(dummy_pdf_path):\n        os.remove(dummy_pdf_path)\n","lang":"python","description":"This quickstart demonstrates the simplest way to extract all text from a PDF file using the high-level `extract_text` function. The example includes creating a dummy PDF for demonstration purposes."},"warnings":[{"fix":"Upgrade to version `20251230` or newer. This version replaces `pickle` with `json` for CMap storage. If you have custom `pickle` CMaps, you must convert them to JSON format using `tools/convert_cmaps_to_json.py` (included in the library). [cite: 2 (release notes 20251230), 11]","message":"Arbitrary Code Execution Vulnerabilities (CVE-2025-64512 and CVE-2025-70559) due to insecure deserialization of CMap cache files via Python's `pickle` module. This allowed attackers to execute arbitrary code by providing malicious PDF files or pickle files. [cite: 2 (release notes 20251230), 11, 12]","severity":"breaking","affected_versions":"<20251230"},{"fix":"Avoid using the third argument for `PDFObjRef` as it is no longer supported and can lead to `TypeError` with corrupt PDF object references.","message":"The third argument (generation number) to `PDFObjRef` was deprecated.","severity":"deprecated","affected_versions":"Introduced in 20250324"},{"fix":"Verify if text can be copy-pasted correctly from a PDF viewer; if it's gibberish there, `pdfminer.six` will also struggle. For scanned PDFs, combine `pdfminer.six` with an OCR library (e.g., `pytesseract`). Consider adjusting `LAParams` for layout analysis.","message":"Textual output may contain raw character ID's (e.g., `(cid:x)` values) instead of readable characters for certain PDFs, especially those with non-standard font encodings or missing font data. This often happens when text cannot be properly converted to Unicode.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For large PDFs, consider extracting text page by page or in chunks using the `page_numbers` argument in functions like `extract_text` to manage memory usage more effectively.","message":"Processing very large PDF files can lead to significant memory consumption and performance issues.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'activ':48 'address':53 'analysi':66,68 'analyz':20 'bug':54 'cjk':41 'communiti':6 'community-maintain':5 'data':28 'document':22,65 'element':33 'encrypt':44 'enhanc':60 'extract':26,64 'featur':57 'fix':55 'focus':24 'fork':8 'frequent':51 'imag':35 'inform':30 'languag':42 'layout':29,67 'librari':16,46 'like':34 'maintain':7,49 'new':56 'origin':11 'pars':18 'parser':62 'pdf':21,39,61 'pdfminer':12 'pdfminer.six':1,2 'power':14 'python':15 'releas':52 'secur':59 'specif':40 'support':37 'text':27,63 'various':38","created_at":"2026-03-29T06:07:39.305938+00:00","updated_at":"2026-04-16T17:57:00.818561+00:00","problems":[{"fix":"Ensure you have `pdfminer.six` installed correctly and not the old `pdfminer`. If you have both, uninstall the old one. Use `pip install pdfminer.six` or `pip install --upgrade pdfminer.six`. If using a virtual environment, activate it first.","cause":"This error often occurs because the `pdfminer.six` library, which contains the `high_level` module, is either not installed, or there's a conflict with the older, unmaintained `pdfminer` package.","error":"ModuleNotFoundError: No module named 'pdfminer.high_level'"},{"fix":"You can attempt to extract text by providing the correct password using the `password` argument in functions like `extract_text`. If there's no password, you might be able to bypass the check by setting `check_extractable=False` in some lower-level functions, though this is not always recommended for security-restricted documents.","cause":"This error indicates that the PDF document is encrypted or has usage restrictions that prevent text extraction.","error":"pdfminer.pdfdocument.PDFTextExtractionNotAllowed: Text extraction is not allowed"},{"fix":"Verify that `pdfminer.six` is the only PDFMiner-related package installed and is accessible in your Python environment. Uninstall any older `pdfminer` installations (e.g., `pip uninstall pdfminer`) and ensure `pdfminer.six` is properly installed (`pip install pdfminer.six`). Also, ensure you are importing `from pdfminer.high_level import extract_text` or similar.","cause":"This typically arises when code written for `pdfminer.six` attempts to use the `high_level` module, but an older `pdfminer` library (which does not have this module) is being imported or is shadowing the `pdfminer.six` installation.","error":"AttributeError: module 'pdfminer' has no attribute 'high_level'"},{"fix":"This is often a limitation of the PDF itself. A quick check is to copy-paste the text from a PDF viewer; if it's gibberish, `pdfminer.six` likely won't do better. For programmatic solutions, one might need to apply custom character mapping or use OCR for such PDFs.","cause":"This is a common issue where `pdfminer.six` cannot map a character ID (CID) to a Unicode character, often due to custom fonts, non-standard PDF encoding, or embedded fonts not providing sufficient information for proper decoding.","error":"(cid:x) values in textual output"},{"fix":"This typically points to an issue with a specific, non-standard PDF file. There isn't a universal code fix, but sometimes updating `pdfminer.six` to the latest version can resolve issues with certain malformed PDFs, as the library often adds robustness for such cases.","cause":"This `KeyError` (or similar for keys like 'Type', 'Resources', 'MediaBox') often indicates that the PDF document is malformed or does not strictly adhere to the PDF specification, missing expected dictionary keys that `pdfminer.six` anticipates.","error":"KeyError: 'N'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"20260107","cli_name":"pdfminer","cli_version":"sh: 1: pdfminer: not found","type":"library","homepage":null,"github":"https://github.com/pdfminer/pdfminer.six","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pdfminer-six/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":"verified"}}