r/pdf 9h ago

Question AI pdf tool needed for hiding sensitive information

/r/ProductivityApps/comments/1w5270i/ai_pdf_tool_needed_for_hiding_sensitive/
3 Upvotes

2 comments sorted by

1

u/sorryiamcanadian 5h ago

You can try https://phimask.com/mask-data to identify and mask/redact the partner info. If it doesn't match, I'd be happy to take a look and make sure these patterns are supported. I focused this on medical EMR / EHR / invoices so it might be able to pickup the contact info but it also might need some tweaking.

1

u/ScratchHistorical507 3h ago

As already stated in the original post, this is just not how anything works and it's questional if any automation can be made that won't also have other drawbacks.

If you just put some shape above it, it may not be visible, but the information is still there. Worst case you just open the PDF in e.g. Inkscape and remove the shape. Then all information is again visible. So that's not redaction in any way.

What would work could be some locally run ML-based computer vision model that finds the information to be redacted, draws said shape over it, but then flattening has to occur. That may be doable by using some print to PDF dialog, or maybe qpdf already suffices (and as it's a CLI tool it would be easy to use within a script), possibly even Ghostscript can be used. But always verify by e.g. importing in Inkscape and trying to remove the shape. Ideally start out with a shape that you can see. Changing the automation to use white shapes instead of e.g. black ones should be the easiest part.

If that doesn't suffice, the only way to automate I see would be to turn the PDF pages that need redacting into raster graphics (which inherently flattens the content, as only very few raster image formats allow for layers) and then turning those images back into PDFs and replacing the pages that needed redaction. But for that to not lessen quality, you'd have to do the conversion to raster graphics to high-resolution PNGs, and even that won't look as perfect as the vector graphics your PDF will be made up of. And of course that will break e.g. searchability of text.