← All articles

How to Redact PII From PDFs Before Sending Them to an LLM

A practical pipeline for sending sensitive PDFs and scans to an LLM: reliable OCR, layered detection, human review, true removal, an audit trail and testing on realistic documents.

The short answer: to send PDFs to an LLM without exposing personal data, (1) get reliable text out of every page, including scans, (2) find the personal and sensitive values with more than one detector, (3) have a person review what was found where the stakes are high, (4) remove the values from the file itself rather than drawing boxes over them, and (5) keep a record of what was removed and why. Test the whole chain on documents that look like your real intake, including bad scans, before you trust it.

This question comes up constantly in developer communities: teams want to run bank statements, claims, medical letters or contracts through a model, and the documents are full of names, addresses, account numbers and IDs.

1. Get text you can trust, including from scans

Detection can only find what the text layer contains. Born-digital PDFs usually have a clean text layer. Scans, faxes and phone photos do not, so they go through OCR first.

This is where many redaction pipelines quietly fail. In our own test of two open-source OCR engines (docTR and Docling) on the same business documents captured clean and degraded, stains, skew, low light, photocopies and crops barely mattered: 94-100% of field values were still recoverable. Blur was the exception: only 13-25% of field values survived. A value the OCR never read is a value your PII detector never sees, and it stays visible in the image.

Practical rule: measure capture quality at intake and route blurry pages to a person instead of trusting automated redaction on them.

2. Detect with more than one method

No single detector catches everything:

  • Patterns (regular expressions, checksums) are precise for structured values: card numbers, IBANs, national IDs, phone numbers. They miss variations in spacing and formatting, and scripts they were not written for (for example Indian-script digits).
  • Named-entity models catch names, organisations and addresses that have no fixed format, but they need tuning for your document types and languages.
  • Custom entities cover what is sensitive in *your* business: policy numbers, claim IDs, internal account references.

Open-source tools such as Microsoft Presidio combine these approaches and are a reasonable starting point. Expect to add recognisers for your own formats and countries.

3. Put a person in the loop where it matters

Detection produces candidates, not decisions. For regulated or high-impact documents, show reviewers the proposed redactions on the page, let them accept, reject or add, and record their choice. Sample-check low-risk batches rather than skipping review entirely.

Note that flagging a value is not the same as removing it, and redaction is not an access-control decision: it does not decide who is allowed to see the rest of the document.

4. Remove the value, not just its appearance

A black rectangle drawn over text in a PDF often leaves the text underneath, selectable and searchable. Proper redaction removes the characters from the text layer and the pixels from any page image, and strips metadata and hidden layers. Always re-open the output and try to copy, search and extract the redacted areas.

5. Keep an audit trail

For each document, record what was detected, what was removed, who approved it and which policy applied. When someone asks why a value was or was not redacted, you need an answer that does not depend on rerunning a model.

6. Decide where the processing runs

If the reason for redacting is that the documents cannot leave your environment, the redaction step itself cannot be a cloud service that receives the originals. Run OCR, detection and redaction inside your own network, on-premises or in your own cloud account, and send only the redacted output to the LLM.

Also be clear about what redaction achieves: removing identifiers before a model call reduces exposure, but on its own it is not the same as formal de-identification under rules such as HIPAA, which has its own methods and requirements.

7. Test on realistic documents before production

Do not test redaction on real customer files, and do not test it only on clean PDFs. Use documents where you know every sensitive value in advance, in the formats and capture conditions you will actually receive, and score each one: was every value removed, and was anything removed that should not have been?

GritWorks' free sample packs are built for this: fictional bank, insurance, healthcare, KYC and Indic-language documents, each clean and degraded, with the expected value and position of every field. Get a free sample pack.

Where GritWorks fits

GritRedact finds PII, PHI and custom entities in PDFs, images and audio, applies your policy with human review, removes the values permanently and keeps an audit trail. It runs fully offline on-premises (Docker, no network egress) or as sales-assisted SaaS. If you are planning to send sensitive documents to an LLM, book a working session and bring a few representative (non-production) examples.

KEEP READING

More perspectives on enterprise unstructured data.

Browse the blog