REWRITEPDF(1)
π REWRITEPDF(1) β rewritepdf.pl
okay so bestie, this is a page from the User Contributed Perl Documentation section, and honestly? it's a whole little glow-up machine for PDFs. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
rewritepdf.pl β literally rebuilds a PDF file. that's it, that's the vibe. π¦
πΈ SYNOPSIS πΈ
rewritepdf.pl [options] infile.pdf [outfile.pdf] [password(s)]\n";
Options:
-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
(yes, that \n"; is really in there. it's giving copy-paste artifact and we respect it π)
π the options, one by one
-c,--cleanseβ seek and destroy unreferenced metadata hiding in the document π₯-C,--clearannotsβ remove all annotations (forms included, no survivors) π-d,--decodeβ uncompress any encoded elements-f,--filter=nameβ compress all elements with this filter (you can use it more than once, go off)-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β printCAM::PDFversion-p,--passopass upassβ set a new owner and user password-P,--prefsprint modify copy addβ set boolean permissions for the document
π about those password arguments
the optional password arguments are needed to open password-protected PDF files. periodt. here's an example of password-protecting and then unprotecting it in sequence:
rewritepdf.pl --pass SecretPass SecretPass orig.pdf passworded.pdf
rewritepdf.pl --decrypt passworded.pdf unprotected.pdf SecretPass
so⦠if you want to prevent people from being able to perform that latter step, then tighten your permissions:
rewritepdf.pl -p Secret Secret -P 1 0 0 0 orig.pdf passworded.pdf
which means that users can print the passworded PDF, but not change it, copy-and-paste from it, or append to it. no cap, that's the whole lock-down vibe π
π DESCRIPTION π
read and write a PDF document, and possibly modify it along the way. main character energy for a file utility honestly.
β οΈ okay this is the important part, bestie, pay attention β the--cleanseoption could possibly break some PDFs which use undocumented or poorly documented PDF features. namely, some PDFs implicitly store theirFontDescriptorobjects just before their Font objects, without explicitly referring to the former. cleansing removes the former, causing Acrobat Reader to choke. π so yeahβ¦ not every cleanse is a slay.
we recommend that you avoid the --decode and --filter options, as we're not sure they work right any longer. they're lowkey giving deprecated. π
π¦ SEE ALSO π¦
CAM::PDF β go read that one too, iykyk π
π§ AUTHOR π§
See CAM::PDF
that's the whole page, bestie. it's giving perl v5.42.3 realness, dated 2013-08-15, and archived forever like a vintage tumblr post. mwah πβ¨
π¦ where this page comes from
- nixos 26.05: perl5.42.3-CAM-PDF 1.60
- nixpkgs unstable: perl5.42.3-CAM-PDF 1.60
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms