De-identify a PDF
Pass a PDF, get a de-identified PDF. The PDF needs extractable text — scanned image-only PDFs aren't supported yet. Image de-identification is coming soon.
- Python
- TypeScript
from custodian_labs import GuardianLayer
result = GuardianLayer().deidentify_file("report.pdf", masking_type="transform")
with open("deid_report.pdf", "wb") as f:
f.write(result.content)
import { writeFile } from "node:fs/promises";
import { GuardianLayer } from "@custodianlabs/sdk";
const result = await new GuardianLayer().deidentifyFile("report.pdf", { maskingType: "transform" });
await writeFile("deid_report.pdf", result.content);
Use redact when reviewers should see values were hidden, or placeholder to show labels like [NAME].
For Word files, see De-identify a Word document.
Prefer no code? Use the Dashboard
Everything on this page also works in the Dashboard. Open API Testing, pick your key, paste text or upload a file, choose the mode and the types of data, then click Mask Now.
Output unchanged?
Check the PDF has selectable text, it's really a .pdf, and pii_entities isn't too
narrow.