REWRITEPDF(1)

πŸ“¦ version 1.60, in nixos 26.05, nixpkgs unstable

πŸ’… 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 β€” 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

πŸ” 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 --cleanse option could possibly break some PDFs which use undocumented or poorly documented PDF features. namely, some PDFs implicitly store their FontDescriptor objects 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