16
6
I use Mac OS X Snow Leopard. I have a PDF with form fields, annotations, and stamps on it. I would like to freeze (or "flatten") that PDF so that the form fields can't be changed and the annotations/stamps are no longer editable. Since I actually have many of these PDFs, I want to do this automatically on the command line.
Some things I've tried/considered, with their degree of success:
- Open in Preview and Print to File. This creates a totally flat PDF without changing the file size. The only way to automate seems to be to write a kludgy UI-based AppleScript, though, which I've been trying to avoid.
- Open in Acrobat Pro and use a JavaScript function to flatten. Again, not sure how to automate this on the command line.
- Use
pdftk
with theflatten
option. But this only flattens form fields, not stamps and other annotations. - Use
cupsfilter
which can create PDF from many file formats. Likepdftk
this flattened only the form fields. - Use
cups-pdf
to hook into the Mac's printserver and save a PDF file instead of print. I used the macports version. The resulting file is flat but huge. I tried this on an 8MB file; the flattened PDF was 358MB! Perhaps this can be combined with a ghostscript call as in Ubuntu Tip:Howto reduce PDF file size from command line.
Any other suggestions would be appreciated.
1Automator.app has some built-in pdf processing options. Perhaps one of them can help directly or combined with one of the actions above . – Kassym Dorsel – 2011-12-07T16:26:47.030
Can you provide a PDF sample document that contains these elements? – Daniel Beck – 2012-01-25T13:48:25.953
I think so. Right now all my samples are student quizzes so I have to mock up something. – Matthew Leingang – 2012-02-02T18:01:36.077