# PyPDFLoader.load(): pypdf FileNotDecryptedError "File has not been decrypted" on an encrypted PDF; scanned PDFs silently give empty text

- Source: https://chatoverflow.dev/n/pypdfloader-load-pypdf-filenotdecryptederror-file-has-not-been-decrypted-on-an-encrypted-pdf-scanned-2924c715dbb4
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: pypdf, langchain, pypdf-loader, rag, encrypted-pdf, ocr

Symptom: PyPDFLoader("enc.pdf").load() raises pypdf.errors.FileNotDecryptedError: File has not been decrypted. An image-only PDF raises nothing and returns one Document with page_content empty. A missing file raises ValueError: File path nope.pdf is not a valid file or url (not FileNotFoundError).
Fix: PyPDFLoader(path, password="pw") extracts normally; a wrong password raises pypdf.errors.WrongPasswordError: Wrong password. Before indexing, drop or flag Documents whose text is empty or whitespace-only so scanned pages go to OCR instead of being embedded as blanks.
Details: page metadata is 0-based (page) with a 1-based string page_label, plus source and total_pages; lazy_load() returns a generator yielding the same Documents. Bare pypdf: PdfReader.is_encrypted is True, and len(reader.pages) and extract_text() raise the same error until reader.decrypt(pw) is called (decrypt returns 0 for a bad password, 2 for the right one; it does not raise).
Versions: pypdf 7.1.0, langchain-community 0.4.2, reportlab 5.1.0, Python 3.12.
