Audit a PDF for metadata leakage (author, working title, forbidden client names), encryption, JavaScript, launch actions and embedded files, with a fix per finding and exit codes 0/1/2. Use before sending a PDF externally, when triaging an inbound PDF, or running a PDF security review.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Pdf Toolkit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/borghei-pdf-toolkit)
---
name: pdf-toolkit
description: >
Audit a PDF for metadata leakage (author, working title, forbidden client
names), encryption, JavaScript, launch actions and embedded files, with a
fix per finding and exit codes 0/1/2. Use before sending a PDF externally,
when triaging an inbound PDF, or running a PDF security review.
license: MIT + Commons Clause
metadata:
version: 1.0.0
author: borghei
category: documents
domain: document-automation
updated: 2026-05-04
python-tools: pdf_auditor.py
tech-stack: pdf
tags:
- pdf
- document-audit
- metadata
- redaction
- security
---
# PDF Toolkit
Audit `.pdf` files for metadata, page count, encryption status, embedded JavaScript, embedded files, and PDF version — using the standard library only.
---
## Table of Contents
- [Keywords](#keywords)
- [Quick Start](#quick-start)
- [Core Workflows](#core-workflows)
- [Tools](#tools)
- [Reference Guides](#reference-guides)
- [Templates](#templates)
- [Best Practices](#best-practices)
- [Scope & Limitations](#scope--limitations)
---
## Keywords
pdf, pdf audit, pdf metadata, pdf review, pdf leakage, pdf security, redaction, document handoff
---
## Clarify First
Before running the audit, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
- **Audit purpose (pre-handoff metadata scrub, inbound security triage, or bulk outbound check):** selects which of the 3 workflows and which fields you act on.
- **Recipient / handling context (external party, managed laptop):** sets what counts as a leak or a threat worth quarantining.
- **Expected legitimate metadata (who the author/title should be):** without it you can't distinguish a leak from expected data.
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
## Quick Start
```bash
python3 scripts/pdf_auditor.py assets/flawed_leaky.pdf --expected-author "Jane Doe" --forbid Globex
```
Real output (excerpt):
```
Read: PDF 1.4, 1 page object(s), 386 bytes, 2 Info field(s), 0 XMP field(s)
Title DRAFT - internal pricing
Author Bob (intern), Globex Ltd
1. [high] javascript: /JavaScript /JS (app.alert\(1\)) >> /Names << /EmbeddedFiles ...
rule: any /JS or /JavaScript key
fix: Do not open on a managed laptop. Inspect in a sandbox; ...
...
FIX 5 issues
```
Every finding quotes the value found, the rule, and a fix. The report ends with a verdict line (`PASS: no findings` or `FIX n issues`) and at most three ranked next actions.
### Exit codes
| Code | Meaning |
|------|---------|
| 0 | No findings |
| 1 | Findings to act on |
| 2 | Unusable input: missing, directory, unreadable, empty, or not a PDF (`BLOCKED: <reason>` on stderr) |
Options: `--expected-author NAME`, `--forbid TERM` (repeatable), `--format text|json` (`--json` is an alias), `--input PATH`.
Samples: `assets/sample_clean.pdf` (exit 0), `assets/flawed_leaky.pdf` (exit 1), `assets/malformed_not_a_pdf.pdf` (exit 2).
---
## Core Workflows
### Workflow 1: Pre-Handoff PDF Metadata Audit
**Goal:** Stop leaking author identity, prior client names, or document history when handing a PDF to an external party.
**Steps:**
1. Run: `python3 scripts/pdf_auditor.py document.pdf --expected-author "Your Name" --forbid "Prior Client"`
2. Review metadata fields:
- `Author` matches the sender (not "Bob's intern" from a prior project)
- `Title` matches the document, not a leftover working title
- `Producer` doesn't reveal an internal-only PDF tool
- `CreationDate` and `ModDate` are reasonable for the deal
3. If metadata leaks, re-export from source with cleaned properties (or use a redaction tool)
**Time Estimate:** 2-3 minutes per document.
### Workflow 2: PDF Security Triage
**Goal:** Decide whether a received PDF can be opened safely on a managed laptop.
**Steps:**
1. Run audit
2. JavaScript indicator present → quarantine; review in a sandbox
3. Embedded files indicator present → list of file types; quarantine if unexpected
4. Encrypted with non-empty owner password → request password from sender via separate channel
5. Decision: open / quarantine / reject
**Time Estimate:** 1-2 minutes per inbound document.
### Workflow 3: Bulk Audit of an Outbound Document Set
**Goal:** Audit every PDF in a folder before zipping for a customer or partner.
**Steps:**
1. Loop (records each exit code; BLOCKED files exit 2 and are logged, not parsed):
```bash
: > audit.jsonl; : > audit.blocked
for f in *.pdf; do
out=$(python3 scripts/pdf_auditor.py "$f" --format json 2>/tmp/audit.err); rc=$?
if [ "$rc" -eq 2 ]; then echo "$f: $(cat /tmp/audit.err)" >> audit.blocked
else printf '%s\n' "$out" >> audit.jsonl; [ "$rc" -eq 1 ] && echo "findings: $f"; fi
done
```
2. Check each line's `verdict` and `findings`
3. Re-export problem files from source
4. Re-run audit until clean
**Time Estimate:** 1-2 minutes per file.
---
## Tools
### pdf_auditor.py
Reads a PDF using stdlib parsing — no `pypdf` or `pdfplumber` required. Detects:
- PDF version (from header)
- Page count (via `/Type /Page` object scan)
- File size
- Document Info / XMP metadata (Title, Author, Subject, Keywords, Producer, Creator, CreationDate, ModDate)
- Encryption status (`/Encrypt` reference present)
- JavaScript (`/JS`, `/JavaScript`), additional actions (`/AA`) and `/Launch` actions
- Findings against `--expected-author` and `--forbid` terms, plus a working-title heuristic
- Embedded files indicator (`/EmbeddedFiles`)
```bash
python3 scripts/pdf_auditor.py document.pdf
python3 scripts/pdf_auditor.py document.pdf --format json
```
**Limits:**
- Does **not** extract text content — pure PDF text extraction with stdlib is unreliable. For text extraction install `pdfplumber` or `pypdf` separately.
- Cannot decrypt encrypted files.
- Detects only the presence of JavaScript/embedded files, not their behavior.
---
## Reference Guides
- **`references/pdf_handoff_guide.md`** — What to scrub from PDFs before external send; PDF/A and PDF/UA basics; common leakage patterns
---
## Templates
- **`assets/pdf_handoff_checklist.md`** — Pre-send PDF sign-off checklist
---
## Best Practices
- **Re-export rather than redact.** Redaction tools that "remove" content can leave it recoverable. The safest path is regenerating the PDF from the source document with sensitive fields removed.
- **Scrub document properties at the source.** In Word: File → Inspect Document → Document Inspector. In Pages: File → Properties. Then export to PDF.
- **Don't trust filenames.** A file named `Public-Report.pdf` can carry private metadata indistinguishable to the human eye.
- **Use PDF/A for archival.** PDF/A removes JavaScript and external dependencies, making documents safe for long-term archive.
---
## Scope & Limitations
**In Scope:**
- Read-only audit of `.pdf` files with `scripts/pdf_auditor.py`, using standard-library parsing with no `pypdf` or `pdfplumber`
- PDF version, page count, file size, Info dictionary and XMP metadata, encryption status, and JavaScript and embedded-file indicators
- Three workflows: pre-handoff metadata audit, inbound security triage, and bulk audit of an outbound set with JSON output
- A handoff guide covering leakage patterns, re-export versus redaction, and PDF/A and PDF/UA basics
**Out of Scope:**
- Extracting text or tables from a PDF
- Decrypting, editing, redacting or re-exporting PDFs; fixes happen in the source document
- Analysing whether embedded JavaScript or attachments are malicious; that needs a sandbox
- Producing PDFs or HTML documents (see `markdown-html/md-document/`)
**Important Caveats:**
- The auditor scans the raw file bytes with pattern matching and does not decompress streams. Page counts, metadata and indicators stored inside compressed object streams can be missed, so a clean result is not proof that nothing is there.
- A JavaScript or embedded-file indicator means the marker is present, not that the file is harmful.
- The working-title check (draft/wip/internal/tbd/untitled) is a heuristic. Only you know which author and client names are expected, so pass them with `--expected-author` and `--forbid`; without them the tool does not judge the author.
---
## Integration Points
- Pairs with `legal/` for redacted contract handoffs
- Pairs with `c-level-advisor/board-deck-builder` for board pack handoff
- Used by `marketing/` for whitepaper / case-study handoff