惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
爱范儿
爱范儿
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
有赞技术团队
有赞技术团队
美团技术团队
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
J
Java Code Geeks
Martin Fowler
Martin Fowler
I
InfoQ
小众软件
小众软件
MongoDB | Blog
MongoDB | Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
PDF Redaction in Rust — Why "Delete the Text" Isn't Enough
hiyoyo · 2026-05-06 · via DEV Community
Cover image for PDF Redaction in Rust — Why "Delete the Text" Isn't Enough

hiyoyo

All tests run on an 8-year-old MacBook Air.
All results from shipping 7 Mac apps as a solo developer. No sponsored opinion.
Real PDF redaction is harder than it looks. The naive approach — draw a black rectangle over text — doesn't actually remove the text from the file.
Here's what proper redaction requires.

The problem with naive redaction
A PDF with a black rectangle drawn over sensitive text still contains that text in the file structure. Anyone with a PDF editor can remove the rectangle and read the original content.
This has caused real security incidents. Legal documents, medical records, government reports — all leaked because someone drew a box over text and called it redacted.

What actual redaction requires

Identify the content to redact (text, images, or regions)
Remove the actual content from the PDF's content streams
Replace with a filled rectangle
Remove any references in the document structure
Rebuild the PDF without the redacted content in the object stream

Step 2 is where naive implementations fail. Removing visible rendering is not the same as removing the data.

The lopdf approach
With lopdf, you're working directly with PDF objects. Redaction means modifying content streams:
rustfn redact_text_in_stream(content: &[u8], target: &str) -> Vec {
// Parse PDF content stream operations
// Find text rendering operations containing target
// Replace text content with spaces or remove operations
// Rebuild content stream

// This is genuinely complex — PDF content streams
// interleave text positioning and rendering commands
todo!("non-trivial implementation")

Enter fullscreen mode Exit fullscreen mode

}
PDF content streams aren't plain text. They're a sequence of operators and operands. Text appears across multiple operators: font selection, positioning, encoding, rendering. A complete redaction implementation needs to parse all of these.

What I ship in PDF Vault
Hiyoko PDF Vault implements region-based redaction: the user selects a region, we remove all content operations that render within that region, then fill with a solid rectangle.
It's not forensic-grade redaction. It removes content from the file structure rather than just drawing over it. For the use case — personal documents, not classified government files — it's appropriate.
For truly sensitive documents requiring certified redaction, professional tools with documented audit trails are the right choice. I'm honest about this in the app description.

The verdict
True PDF redaction is a solved problem in professional tools. In a Rust implementation, it's achievable but requires careful PDF content stream parsing. The naive approach (draw a rectangle) should never be called redaction.
Know what level of redaction your users actually need before deciding how to implement it.

If this was useful, a ❤️ helps more than you'd think — thanks!
Hiyoko PDF Vault → https://hiyokoko.gumroad.com/l/HiyokoPDFVault
X → @hiyoyok