REWRITEPDF(1p)

πŸ“¦
version 1.60 Β· 2 versions
  • 1.60 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.60 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 the CAM::PDF version
  • -p, --pass opass upass β€” set a brand new owner password and user password
  • -P, --prefs print 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 --cleanse option could possibly break some PDFs that use undocumented or poorly documented PDF features. like, specifically: some PDFs implicitly store their FontDescriptor objects 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