Skip to content

Redact PDF: keep the text you didn't cover searchable - #87

Merged
kingrishabdugar merged 2 commits into
mainfrom
feat/redact-keep-text
Oct 5, 2026
Merged

kingrishabdugar merged 2 commits into
mainfrom
feat/redact-keep-text

Conversation

@kingrishabdugar

@kingrishabdugar kingrishabdugar commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Fixes #85 (the scrolling half shipped in #86).

Redacted pages are still saved as images with the marks burned in, so nothing under a mark can be recovered. Until now that also meant the rest of the file lost its text. Now the text outside the marks is added back as an invisible layer, the way OCR tools do it, so it can be searched, selected and copied again.

What gets added back. A text run is kept only when:

  • it doesn't touch any mark (same padding as the search marks, so it errs on the side of leaving text out), and
  • it actually shows on the rendered page. Every letter's spot is checked on the page image; text that sits under a black box that was already in the file, or is drawn in the page colour, is left out. This stops an old fake redaction from coming back as searchable text.

A run that's only partly covered is dropped as a whole, rather than guessing where letters fall.

Font. The layer uses a glyphless Type0 font with an identity ToUnicode map, so any script (Hindi, Tamil, accented Latin…) is searchable, and nothing is ever drawn with it.

Option. A "Keep the rest of the text searchable" checkbox (on by default) gives an image-only file when unticked. PDF to scanned PDF is unchanged: still no text.

Copy. The hint, the intro and two FAQ answers are updated in all 16 languages.

Tests:

  • The existing e2e now checks the redacted file keeps "Annual Report" and the rest, but not the marked heading.
  • New e2e covers four cases that must stay out: text under an existing black box, white-on-white text, a single invisible letter, and a partly covered line. It also checks the checkbox gives an empty text layer.
  • Checked in a second reader (MuPDF): text extracts and word positions line up with the page.

Redacted pages are still saved as images, so nothing under a mark can
be recovered. The text outside the marks is now added back as an
invisible layer, so the file can be searched, selected and copied.

Text is only added back when it shows on the rendered page: runs that
touch a mark, sit under an existing black box or are drawn in the
page colour are left out. A checkbox turns it off for an image-only
file.

Part of #85.
# Conflicts:
#	src/i18n.ts
#	src/i18n/bn.json
#	src/i18n/de.json
#	src/i18n/es.json
#	src/i18n/fr.json
#	src/i18n/hi.json
#	src/i18n/id.json
#	src/i18n/it.json
#	src/i18n/mr.json
#	src/i18n/nl.json
#	src/i18n/pl.json
#	src/i18n/pt.json
#	src/i18n/ta.json
#	src/i18n/te.json
#	src/i18n/tr.json
#	src/i18n/vi.json
#	tests/app.e2e.ts
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Deploying fizzdoc with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8b35cf0
Status: ✅  Deploy successful!
Preview URL: https://63c43ae9.fizzdoc.pages.dev
Branch Preview URL: https://feat-redact-keep-text.fizzdoc.pages.dev

View logs

@kingrishabdugar
kingrishabdugar merged commit f8d68e1 into main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redact a PDF: Not able to scroll the pdf pages on android browser for Redaction

1 participant