REWRITEPDF(1p)
π REWRITEPDF(1p) π
okay so bestie, welcome to rewritepdf from the User Contributed Perl Documentation corner of the world π«Ά this is a little Perl script that lives in the CAM::PDF universe and it is literally here to rebuild your PDF files. no cap.
β¨ NAME β¨
rewritepdf β rebuild a PDF file. that's it. that's the whole job. π
πΈ SYNOPSIS πΈ
here's the vibe, verbatim, don't touch it:
rewritepdf [options] infile.pdf [outfile.pdf] [password(s)]\n";
and the options, in all their glory:
-c --cleanse seek and destroy unreferenced metadata in the document
-C --clearannots remove all annotations (including forms)
-d --decode uncompress any encoded elements
-f --filter=name compress all elements with this filter (can use more than once)
-X --decrypt remove encryption from the document
-o --order preserve the internal PDF ordering for output
-v --verbose print diagnostic messages
-h --help verbose help message
-V --version print CAM::PDF version
-p --pass opass upass set a new owner and user password
-P --prefs print modify copy add set boolean permissions for the document
okay and now the same energy, but explained, because i love you:
-c,--cleanseβ go on a little hunt π΅οΈββοΈ and destroy any unreferenced metadata chillin' in the document-C,--clearannotsβ yeet every single annotation out, forms included, gone, bye π-d,--decodeβ uncompress anything that's encoded-f,--filter=nameβ compress all the elements using this filter (and yes you can use this more than once, go off)-X,--decryptβ strip the encryption off the document-o,--orderβ keep the internal PDF ordering for the output, don't mess with it-v,--verboseβ spill the diagnostic messages, we love a chatty king-h,--helpβ the verbose help message-V,--versionβ prints theCAM::PDFversion-p,--passopass upass β set a brand new owner password and user password-P,--prefsprint modify copy add β set boolean permissions for the document
π the password tea π
so the optional password arguments? yeah, those are for opening PDFs that are password-protected. she's locked, bestie, you need the key π
here's an example of password-protecting a file and then unprotecting it, in sequence:
rewritepdf --pass SecretPass SecretPass orig.pdf passworded.pdf
rewritepdf --decrypt passworded.pdf unprotected.pdf SecretPass
now⦠if you want to stop people from being able to do that second step, you gotta tighten your permissions:
rewritepdf -p Secret Secret -P 1 0 0 0 orig.pdf passworded.pdf
which means users can print the passworded PDF, but they can't change it, can't copy-and-paste from it, and can't append to it. boundaries, periodt. π«
π¦ DESCRIPTION π¦
it reads a PDF document, writes a PDF document, and maybe, just maybe, modifies it along the way. lowkey iconic.
β οΈ the--cleanseoption could possibly break some PDFs that use undocumented or poorly documented PDF features. like, specifically: some PDFs implicitly store theirFontDescriptorobjects just before their Font objects, without ever explicitly referring to the former. cleansing removes the former, and then Acrobat Reader chokes. π not the vibe.
and listen β we recommend that you avoid the --decode and --filter options, because we're not sure they work right any longer. fr fr. π
π SEE ALSO π
CAM::PDF
π AUTHOR π
See CAM::PDF
okay that's the whole thing, you're a PDF rewriting legend now π
this was perl v5.36.0, dated 2022-12-08, and that's REWRITEPDF(1p) signing off πβ¨
π¦ where this page comes from
- debian bookworm: libcam-pdf-perl 1.60-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcam-pdf-perl 1.60-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcam-pdf-perl 1.60-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcam-pdf-perl 1.60-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcam-pdf-perl 1.60-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms