Guide

PDF Background Removal — Text-Aware Color-Key

How the PDF remover preserves text interiors while stripping page backgrounds, and why it skips the AI model.

Why PDFs don't use the AI model

RMBG-1.4 and BiRefNet are trained on photographs. When fed a document with dense text, they often misclassify the text as "background" and erase it along with the page white. So for PDFs, the tool uses a deterministic colour-key approach instead: any pixel close enough to white becomes transparent.

Soft alpha ramp (not binary)

Earlier versions used a hard threshold (R>240 && G>240 && B>240 → transparent). The problem: anti-aliased text edges have grey pixels (R≈220-240) — these got treated as "background" and erased, hollowing out letters.

The current implementation uses a soft alpha ramp: pixels at exactly 255 are fully transparent, pixels at 230 are fully opaque, and values between are linearly interpolated. Anti-aliased text edges keep their grey shading and stay intact.

Text-interior flood-fill

Even with soft alpha, the inside of a letter O or D would still get punched out (the white interior matches the page background). The tool runs an iterative scanline flood-fill from all 4 image corners — only pixels reachable from a corner via a chain of "transparent or semi-transparent" neighbours become transparent. Enclosed regions (letter interiors) are unreachable from the corners, so they stay opaque.

Why all pages now come through

Previously some pages were silently dropped if a single page failed to render (corrupt font, security restriction). The tool now wraps each page render in a try/catch — failures get a blank placeholder, the loop continues, and you get every other page in the output.

Tips for best results

  • 2× DPI rendering is the default — sharper text edges in the output PNG. Higher DPI = bigger files but cleaner output.
  • Off-white backgrounds (cream, light grey) — try the "Medium" or "Low" strength setting. The default High treats only pure-white as background.
  • Scanned PDFs with paper texture may not strip cleanly — the colour variation in "white" paper exceeds the threshold. Run through a black-and-white filter first.
  • Coloured page backgrounds aren't supported by this tool — use the Image BG Remover on each page individually.