BASALT · JOURNAL

PDF content streams, explained through a redaction failure

2026-09-21 · pdf content stream explained

A PDF page is closer to a drawing program than a word-processing page. Its content stream contains instructions that set fonts, position text, draw paths, and paint images in sequence. What appears on top is not necessarily what exists underneath.

The simplest failure

Imagine a stream that effectively says:

draw the text "Account 123456"
set fill colour to black
draw a filled rectangle over 123456

The viewer paints the text and then the rectangle, so the digits disappear visually. A text extractor reads the text-showing instruction directly and returns the full account number. Removing the rectangle reveals it instantly.

Text is stored as positioned glyphs

PDF text may not be stored in reading order or as ordinary Unicode. Character codes map through fonts, and one visible word can be split across many operations. Safe redaction must identify the glyphs intersecting the mark, remove them, and re-emit surviving content without shifting or changing it.

That is why naïve string replacement is unreliable and why a verifier should test both target absence and neighbor survival.

Images and paths are different objects

A scan is usually an image XObject painted onto the page. Covering it does not edit the image bytes; the image can be extracted intact. Vector diagrams and signatures may be path operations rather than text or images. A complete redaction engine must handle each object class.

OCR adds invisible text positioned above or below the scan, creating two representations that must be removed together.

The page is still not the whole file

Metadata, annotations, form values, attachments, layers, and revision history live outside the page content stream. Page redaction must be paired with PDF sanitization and independent inspection.

Frequently asked questions

Why can I copy text from under a black box?

Because the box is a later drawing instruction and the original text-showing operation remains in the content stream.

Is PDF text stored like paragraphs in Word?

Usually not. It is often a sequence of positioned character codes, which may not follow visual reading order.

Can a PDF page contain both an image and hidden text?

Yes. Searchable scans commonly pair a page image with an invisible OCR text layer.

Doing it in Basalt

Basalt works at the object level: it excises marked glyphs, edits and re-encodes image pixels, removes intersecting paths, and clears OCR text. An independent parser then proves the target is gone and surrounding content survived. Download Basalt.

Redaction that proves itself

Basalt destroys the content you mark, then re-opens the file it wrote and proves the content is gone before it saves anything. Your documents never leave your Mac.

DOWNLOAD BASALT 2.3.0 BUY $29 FREE FOR 24 HOURS · MACOS 13+