What PDF redaction detects — and when it misses
This page explains why certain data is redacted and why some is left alone. If a result looks wrong or something was missed, start here.
Nine categories it detects
| Type | Formats covered | After redaction |
|---|---|---|
| Mobile numbers | 13800138000, 138****, +86 138…, and separator variants | Fully covered |
| ID numbers | 18- and 15-digit, with check digit and region-code validation | Fully covered |
| Bank cards | 16–19 digits, Luhn-checked to avoid false positives | Fully covered |
| Common email formats | Fully covered | |
| Landlines | Area code-number, Area code + space + number | Fully covered |
| Addresses | Province/city/district + street and house number, e.g. "XX Road XX No. XX Room" | Fully covered |
| Dates of birth | Only dates with "born / birthday / date of birth" context | Fully covered |
| Gender / age | "Gender: female", "Li Si, male, born 1990…" | Covered |
| Names | Recognised in ordinary sentences, without a "Name:" label | Given name masked, surname kept |
Number-like fields are checked first: ID check digits, bank card Luhn checks, so stray numbers are not mistaken for private data.
What is never redacted
How names are judged
| Rule | Explanation |
|---|---|
| No label needed | Names in ordinary prose are recognised without a "Name:" prefix |
| Mask given name, keep surname | 陈嘉豪 → 陈██; compound surnames kept: 欧阳志强 → 欧阳██. Lists and contact books need to tell people apart; masking everything makes checking impossible |
| Uncertain names are listed as "possible" | Not ticked by default; you tick them to redact. E.g. "Li Minghui Team" or "Xie Tiancheng Studio" — impossible to tell whether it is a person or an organisation |
| Certain endings are skipped | Names ending in "town / garden / road / street / village / manor" are skipped; those characters cannot be told apart from place names, so better to miss than to redact body text by mistake |
| Names split across lines are missed | When the surname ends one line and the given name starts the next, line-by-line processing cannot recognise them — select manually |
Special layouts
| Scenario | Handling |
|---|---|
| Multi-page PDFs | Page by page; the header shows "X/Y pages with content" and the page break shows "N items on this page" |
| Several people on one page, multiple table rows | Recognised separately, never merged; several people in one paragraph are judged individually |
| Adjacent table cells | When cells have no dividing lines and numbers run together, they are split into segments within the string |
| Fillable form PDFs | Fields you can click and type into are recognised too; their values are removed from the file as well |
| Scans / photographed pages | Pages without a text layer are first processed with local OCR (PP-OCRv4, fully offline) to recover text and per-character coordinates, then the same rules apply; the UI marks which pages used OCR |
Why the mosaic cannot be reversed
It is not a black box drawn over text. Four steps: the source region is resampled into small pixel blocks, discarding glyph detail; the region is flattened to an average colour with random noise, so pixels no longer correspond to the original; the text layer is deleted as well, so copying, searching and extracting return nothing; the result is saved as a new PDF with document properties cleared.
Redacted content cannot be restored, and no "de-mosaic" tool can bring it back.
Eight known limits
| # | Limit | Effect | What to do |
|---|---|---|---|
| 1 | Blurry scans or tiny text (below 200 dpi) | OCR misreads or misses text | Review the results and select missed items manually; an empty automatic result does not mean there is no private data |
| 2 | Long runs of identical digits (e.g. 13655556666) | At low resolution they may be merged into fewer digits | Scan at 300 dpi where possible and check each recognised result |
| 3 | Encrypted PDFs | Cannot be opened | Remove the password before importing |
| 4 | Numbers written with Chinese digits | Not recognised | Select manually |
| 5 | Names ending in "town / garden / road / street / village / manor" | Missed on purpose | Select manually |
| 6 | Names or numbers split across lines | May be missed | Select manually |
| 7 | Uncertain names appear only as "possible" | Not redacted by default | Tick them manually in the list |
| 8 | Handwriting, decorative fonts, stamps | Not recognised | Select manually |
Where these numbers come from
Six test documents with 452 private items produced identical results on Windows and Android, with a maximum coordinate difference of 0.55pt; official documents with no private data produced zero false positives. For scans, eight pages of real paperwork (CV, rental contract, outpatient record, bank statement, shipping label, etc.) were rendered as full-page images with 0.3–1.2 degree skew and noise added. The finished PDF has no text layer at all, so OCR is the only route: all 86 ground-truth items passed (0 missed / 0 leaked / 0 wrongly redacted). All names, numbers and addresses in the test documents were randomly generated fiction.
Original notes and test scripts are in the repository: Detection rules and known limits (repo version), Test scripts and samples。