Resume redaction for blind hiring. A TypeScript SDK that finds personal identifiers on a CV and removes them, rather than covering them up.
It exists because drawing a black rectangle on a PDF redacts nothing. The text stays underneath, selectable and copy-pasteable, and so do the hyperlinks. We needed something our services could call that produces a file you can safely hand to a hiring manager.
The name, the contact block, and the URL written into the body are gone. That is the default style, blur, and it is not a smudge over live text: the characters were destroyed before anything was smoothed. The job title, the dates, and what the candidate actually did are untouched, which is the whole point. The word "Portfolio" is still readable, but the link under it no longer goes anywhere.
What it does not do is make a CV anonymous. Blacking out the name and the contact block is the easy half. A distinctive project, an award, or a line like "cut the $10000 AWS Glue bill by 96%" is one search away from a name, and no target matches any of those. Read Limitations before you decide this is enough.
npm install @remotestar/rsredact openai
Needs Node 20 or newer. @napi-rs/canvas does the rasterizing and is a native dependency, shipped as prebuilt binaries per platform, which is worth knowing before you put this in a Lambda or an Alpine image.
import { readFile, writeFile } from 'node:fs/promises';
import { redact } from '@remotestar/rsredact';
import { openaiProvider } from '@remotestar/rsredact/providers';
const result = await redact(await readFile('cv.pdf'), {
targets: ['name', 'email', 'phone', 'social', 'photo'],
provider: openaiProvider(),
});
await writeFile('cv.redacted.pdf', result.pdf!);
console.log(result.detections); // every box, with what it was and where it came from
console.log(result.audit); // targets, provider, llmCalls, warnings, durationMsAccepts PDF, PNG, JPEG, and WebP. Returns a PDF, page images, or both.
Three things, because each one is a way redaction usually fails.
The text is gone, not hidden. Pages are rendered to pixels, the boxes are painted, and the PDF is rebuilt from those images. Nothing survives but the pixels you can see. getTextContent() on the output returns zero items.
Every link is dead, and that is not an option. No annotation survives into the output, so nothing is clickable and no URL is recoverable, in every mode and for every setting. Whether the visible text of a link is also hidden is a separate question, and the answer is usually no. See below.
The metadata is cleared. A CV PDF very often carries the candidate's name in its Author field and their filename in Title. Both are emptied.
What that costs you: the output is raster, so it is three to four times the size of the input at the default 150 dpi (122 KB in, 457 KB out on a one page resume, and it scales with dpi) and no longer searchable. That is the trade, and it is not negotiable if the goal is that nobody can recover the name.
Those three claims take about ten seconds to check, so check them rather than trust them.
Start with the run's own record.
console.log(result.audit.detectionCounts); // { name: 1, email: 1, phone: 1, 'social+url': 1 }
console.log(result.audit.warnings); // one entry: the default style leaks shapeTwo things about warnings that will bite you if you assume otherwise.
A default run is never empty. blur is the default style and it always warns, because a style that leaves the shape of the text visible should never be applied silently. So warnings.length === 0 is not the test for "nothing went wrong". Either pass style: 'box', which warns about nothing, or filter the style entry out before you look.
And an empty warnings is still not a clean bill of health. In patterns-only mode, and in text mode when the only targets left are visual ones, every model target is skipped in silence. So read detectionCounts against the targets you actually asked for: a target you requested that is missing from the counts either found nothing or never ran, and those two look identical from here.
social+url is not a typo. Two detectors landing on the same box merge into one detection carrying both names, so filter with includes, not ===.
Then look at the file itself. No fonts means no text, and one byte out of pdftotext is the trailing newline:
$ pdffonts cv.redacted.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
$ pdftotext cv.redacted.pdf - | wc -c
1
$ pdfinfo cv.redacted.pdf | head -4
Title:
Subject:
Keywords:
Author:
For text and links in one go, ask pdf.js, which rsredact already depends on:
import { readFile } from 'node:fs/promises';
import { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs';
const data = new Uint8Array(await readFile('cv.redacted.pdf'));
const page = await (await getDocument({ data }).promise).getPage(1);
(await page.getTextContent()).items.length; // 0
(await page.getAnnotations()).length; // 0Both numbers should be 0 on every page. For reference, the test fixture goes from 21 text items and 2 links to 0 and 0. A real one page resume carrying 21 hyperlinks goes from 379 text items and 21 links to 0 and 0.
If you want to see what the input was leaking through its link layer, which is the part no text extractor shows you, read the annotations before you redact:
const urls = (await page.getAnnotations()).map((a) => a.url).filter(Boolean);On that resume this printed 21 URLs, including a LinkedIn profile slug, a personal blog, a GitHub handle, four credential badge URLs that resolve to the candidate's full name, and a mailto: of the address already in the header.
Compared with the alternatives: pdf-redact-tools rasterizes the whole document and detects nothing, so you keep every identifier. PyMuPDF's apply_redactions does genuinely destroy text, but you supply every rectangle yourself and it is AGPL, which decides it for a lot of commercial callers. Drawing a rectangle with a PDF library, which is the usual in-house approach, is the failure the top of this file is about. What rsredact adds is detection joined to a destructive rebuild, plus reading the annotation layer that none of them look at.
Dead links and hidden links are different things
These are two separate axes, and conflating them was the first thing we got wrong.
Dead means the link no longer goes anywhere. That is unconditional. The output is rebuilt from rendered pages, so link annotations, form fields, and embedded actions do not exist in it. There is no option to turn this off and no mode in which a link survives.
Hidden means the reader cannot even read the words that used to be a link. That is a content decision, not a security one, and it defaults to off.
The reason is that hiding link text mostly destroys information for no privacy gain. A CV links an employer's name to the employer's site, a certification like "CKA" to its badge, and a project title to its repository. Once the link is dead, the destination is gone; what is left on the page is the word "CloudSEK" or "CKA", which identifies nobody. Blacking those out costs the reviewer real signal and buys nothing.
linkText |
Link is dead | Link text readable | Use when |
|---|---|---|---|
keep (default) |
yes | yes | Normal blind hiring. Employer names, certifications, and project titles stay readable. |
redact-identifying |
yes | hidden when its destination matches a requested pattern target, readable otherwise | You want a link reading github.com/someone gone. Read the caveat below first. |
redact-all |
yes | no | The output must show no trace that a link was ever there. |
redact-identifying is blunter than it sounds, and worth understanding before you switch it on. It matches the destination against the regexes of the targets you asked for, so only social, url, email, phone, and dob can ever trigger it. Ask for redact-identifying with a model-only target set like ['name', 'photo'] and it does nothing at all. And because the match is on the URL host rather than on any judgement about whose page it is, an employer whose name links to its LinkedIn company page loses that name, while one that links to its own domain keeps it. On the resume we tested, "Embeddings Co" and "Aspora (Vance)" were hidden because both link to linkedin.com/company/..., and "CloudSEK" survived because it links to cloudsek.com.
Separately from all of this, a URL written out as visible text is identifying content in its own right, because a reader can simply type it. That is handled by the url target (any URL) and the social target (known profile hosts), not by linkText. Ask for url and github.com/someone written in the body gets redacted whether or not anything linked to it.
Pass the ones you want. Strings resolve against the built-in list:
| Target | What it covers | Found by |
|---|---|---|
name |
The candidate's own name, wherever it appears | model |
email |
Email addresses | regex |
phone |
Telephone and mobile numbers. A Mobile: label stays put |
regex |
address |
Postal or residential address, not employer locations | model |
social |
LinkedIn, GitHub, X, portfolios, link aggregators | regex |
url |
Any URL | regex |
photo |
A photograph of the candidate, not logos or charts | vision |
signature |
A handwritten signature | vision |
dob |
Date of birth or age | regex |
nationality |
Nationality, citizenship, visa status | model |
gender |
Gender, sex, or pronouns | model |
marital_status |
Marital status, spouse, dependents | model |
employer |
Company names, keeping titles and dates | model |
school |
Institution names, keeping degrees and dates | model |
reference |
Referees and their contact details | model |
"Found by" is what a target needs in order to match anything:
- regex works with no provider and no API key. These targets are also shown to the model when you pass one, which catches the shapes a regex misses.
- model means there is no pattern to match on, so the target only does something when a
provideris set. Without one it finds nothing. Inauto,text, andvisionmode you get a warning; inpatterns-onlyyou get silence. - vision means the page is looked at rather than read. You cannot OCR a face.
The set in the quick start is the contact block and the headshot. It is the right starting point and it is not the whole job, so pick deliberately.
// Contact details. Mostly regex, works without a provider.
'email', 'phone', 'social', 'url'
// The name itself, and the attributes people discriminate on.
'name', 'photo', 'signature', 'address',
'dob', 'nationality', 'gender', 'marital_status', 'reference'
// Where they worked and studied. The strongest bias signal, and the
// most expensive in lost context. Opt in when you want it.
'employer', 'school'Leaving employer and school out is a real choice, not an oversight: a reviewer who cannot see where somebody worked also cannot judge the work. Turning them on reduces prestige bias and costs the reviewer that signal. What neither setting buys you is anonymity, for reasons in Limitations.
If you ask for a model target and pass no provider, the run still succeeds and records what it skipped:
page 1: no provider was passed, so only pattern and link detection ran.
Targets that need judgement (name, address, employer) were not found.
That string lands in result.audit.warnings. Two things about it. The names in the brackets are a fixed example rather than a list of what your run skipped, so compare audit.detectionCounts against what you asked for. And it is only emitted in auto, text, and vision mode, because patterns-only skips every model target by design and says nothing about it.
Read it either way, because a redaction that quietly did less than you asked looks exactly like one that worked.
Define your own by passing an object instead of a string. The description is the whole instruction, so be specific:
targets: ['name', { id: 'clearance', description: 'Security clearance level or ID' }]Add patterns: [/.../ ] and the regexes run before any model call. Add visualOnly: true and it is looked for on the page rather than in the text.
| Option | Default | Purpose |
|---|---|---|
targets |
required | What to look for |
provider |
none | Omit to run pattern and link detection only |
mode |
auto |
auto, text, vision, patterns-only |
linkText |
keep |
keep, redact-identifying, redact-all |
style |
blur |
blur, box, label, pixelate |
dpi |
150 |
Render resolution |
padding |
2 |
Pixels added around every box |
minConfidence |
0.5 |
Drop detections below this |
grid |
{ cols: 24, rows: 36, opacity: 0.35, snapToWords: true } |
Reference grid for vision mode |
ocr |
true |
OCR pages with no text layer, needs tesseract.js |
ocrLanguage |
eng |
Tesseract language code |
output |
pdf |
pdf, images, both |
rsparseUrl |
none | An rsparse instance, for document context |
onProgress |
none | Per stage callback |
Every style destroys the text, because the page is rebuilt from pixels either way. What they differ on is how much they still tell a reader about what was taken.
blur is the default because a blurred CV reads as a deliberate document rather than a censored one, and a reviewer can see that something was removed without being told. pixelate is the same operation drawn back with smoothing off. Both downsample the region to a twelfth of its size first, so the characters cannot be read back out of the output, but the shape survives: how many words, how long each one was, and where the lines broke. That is enough to tell a short name from a long one, and both emit a warning in audit.warnings saying so.
box is the only style that leaves nothing. Pass it when the output goes anywhere you do not control, or when even the length of a name is more than you want to disclose. label is box with the target name printed on the fill, which is useful when a human needs to see that nothing was covered by accident.
The rule is that anything which would make the output untrustworthy throws, and anything that cost you one box warns. Worth knowing before you write a batch loop, because a throw means there is no PDF at all.
| Situation | What happens |
|---|---|
| Input is not a PDF, PNG, JPEG, or WebP | throws UnsupportedInputError |
| A target id does not exist | throws, before anything is read |
openai, @anthropic-ai/sdk, or tesseract.js is needed and not installed |
throws MissingDependencyError, carrying the install command |
| The provider errors, refuses, or has no API key | throws ProviderError, and no PDF comes back |
| A vision target is asked of a provider that cannot see | throws ProviderError |
| The model quotes text that is not on the page | warns, that one detection is dropped |
| The model returns an unreadable grid reference | warns, that one detection is dropped |
| A model target was asked for with no provider | warns, except in patterns-only |
| A page has no text layer and neither OCR nor vision ran | warns, and that page comes back unredacted |
style is blur or pixelate |
warns that the shape of the text is still visible. blur is the default, so this fires unless you ask for box |
All four error classes extend RedactError and carry a code.
A provider is transport plus "give me back parsed JSON". rsredact owns all the prompting, so a new backend is about a hundred lines, or thirteen if you are wrapping your own gateway with customProvider.
import { openaiProvider, anthropicProvider, customProvider } from '@remotestar/rsredact/providers';
openaiProvider({ model: 'gpt-4.1' }) // also Azure, OpenRouter, vLLM, Ollama via baseUrl
anthropicProvider({ model: 'claude-opus-5' })
customProvider({
name: 'internal-gateway',
supportsVision: true,
generate: async (request) => callYourThing(request),
});openai and @anthropic-ai/sdk are optional peer dependencies, loaded only when used. Install just the one you need.
For OpenAI, schemas are rewritten to the strict structured-outputs subset on the way out, so a custom target's schema cannot break the request.
There is also scriptedProvider([...]), which replays canned responses. It is how the test suite runs the whole pipeline without a network call.
Four layers, cheapest first. Each one only handles what the layer below cannot.
Coordinates come from the document, never from the model. A text PDF already carries exact glyph boxes, so those are read directly. A scanned page goes through OCR instead, which gives word boxes.
Regexes catch the mechanical identifiers. Emails, phones, URLs, known profile hosts. No model call, no hallucination, no cost. Guards then throw out the false positives that matter: a phone pattern will happily eat 2019 - 2024 out of an experience section, and blacking out every date range makes a CV useless.
The model reads text, not pixels. It gets the page line by line and returns the substrings to redact, which are then mapped back to the words that produced them. The model only ever has to recognise an identifier, never place one, which is the part models are worst at.
Vision handles what text cannot. You cannot OCR a face, and blind hiring needs the headshot gone. For photo and signature, and for pages with no readable text, the page is sent with a reference grid drawn over it and the model names two corner cells, like C4 to H6. Where words are known, that rectangle is then snapped down to the words inside it, so a coarse cell becomes a tight box.
A grid is the obvious way to ask a model where something is, and it is worse than it looks. At 24x36 on A4 a single cell is still about two lines of body text tall. Ask for a name and the cell you get back also holds the job title. Precise localisation is also the weakest thing a vision model does. So the grid earns its place on exactly the two jobs nothing else can do, photos and unreadable pages, and text handles the rest with the document's own coordinates.
PDFs keep hyperlinks in an annotation layer beside the text, not in it. Text extractors read the text and leave the annotations behind, which is why most PDF-to-text tools lose your URLs. It is also a leak: a CV that renders the word "Portfolio" over https://janesmith.com gives away the candidate in a layer that text extraction never sees.
rsredact reads the annotations for their rects, which arrive in the same coordinate space as the text. Rebuilding the output from rendered pages is what kills them.
It also shows the model each link as visible text -> destination. That is not so the model can hide anything that happens to be a link, which was our first mistake here. It is so a bare label standing in for the candidate's own page, something like "Portfolio" or "Profile", can be judged on where it goes rather than on how it reads, while an employer name or a certification linking somewhere useful is left alone.
One page LaTeX resume, Apple M-series, 12 runs.
Pattern and link detection only, no model call:
| dpi | mean | p50 | p95 |
|---|---|---|---|
| 110 | 235 ms | 209 | 349 |
| 150 | 291 ms | 272 | 369 |
| 200 | 429 ms | 426 | 462 |
Most of that is rasterizing the page, so it scales with dpi and page count rather than with how much text there is.
With a model in the loop, expect the model to dominate. A full run on the same file with gpt-4.1 and targets name, email, phone, social, address, photo takes about 4.6 s and makes 2 calls, one for text and one for the photo.
Calls scale with pages, not with findings. Every page gets one text call, and every page gets a vision call too if any visual target is requested, whether or not that page has a photo on it. So a three page CV with photo in the targets is six calls, not two. Page text is chunked at 12,000 characters, which one CV page never reaches. Images go up at OpenAI's high detail by default, which is the expensive setting: pass openaiProvider({ imageDetail: 'low' }) if you are running at volume and can accept coarser boxes.
DOCX and other office formats are rejected. Their text reflows, so it has no fixed coordinates to redact. Convert to PDF first. rsparse will tell you what a document says, but not where on a page it says it.
OCR is optional and untested in CI. tesseract.js is a peer dependency, loaded only for pages with no text layer. If it is not installed, those pages fall through to vision detection and a warning is recorded rather than the run failing.
A page with no text layer needs either tesseract.js or a vision provider. With neither, that page comes back rendered and completely unredacted, and the only clue is a warning about tesseract. This is the quietest way to get a useless result out of this library. Check audit.textSources for none if you accept scans.
Word boxes on text PDFs are measured, not exact. pdf.js reports the width of a whole text run but not where each character sits inside it, so characters are placed using measured advance widths from a proxy font of the same class, scaled to the run's real width. The error is a fraction of a character, which the default 2 px padding covers. Splitting the width evenly instead, which is the obvious approach, drifts by a full character by mid-line and leaves the first letter of an email address showing.
Redacting the identifiers is not the same as anonymising the CV. This is the limitation to take seriously, and no setting fixes it. Names, emails, and employers are the easy part, because they are identifiers and they look like identifiers. What actually re-identifies a candidate is the detail nobody files under personal information: a Google Summer of Code project, a conference talk, an open source contribution, a line reading "cut the $10000 AWS Glue bill by 96%". Every one of those is a single web search away from a name, and no target matches any of them.
We tested this on a real resume. The contact block went, 21 hyperlinks died, and the remaining text still pointed at exactly one person. employer and school help, because they remove the prestige signal a reviewer reacts to first, but they are coarse and plenty of context survives them. Treat the output as bias-reduced rather than anonymous. If you need anonymity, a person has to read the result and judge whether what is left is too specific.
npm install
npm test # compiles to dist-test, then runs the suite against that
npm run typecheck
The tests generate their own fixture CV, including a hyperlink whose anchor text hides the URL, and assert on both the detections and the pixels. No network and no API key needed.
examples/redact.ts redacts one file and writes the result next to it, which is the fastest way to try this on your own CV:
OPENAI_API_KEY=... npx tsx examples/redact.ts cv.pdf
Drop the key and only pattern and link detection runs, which still removes emails, phone numbers, and every link. The example is not in the published package, so run it from a clone.
MIT
