Skip to content

Instantly share code, notes, and snippets.

@y3nr1ng
Last active March 28, 2024 16:20
Show Gist options
  • Save y3nr1ng/9a24b2f59509c52bd59d5c145158328b to your computer and use it in GitHub Desktop.
Save y3nr1ng/9a24b2f59509c52bd59d5c145158328b to your computer and use it in GitHub Desktop.
Remove text-based PDF watermark
  1. Install the pdftk for the PDF stream, and bbe to do binary replacement (sed for binaries).

    brew install pdftk-java bbe
  2. Decompress the PDF.

    pdftk infile.pdf output uncompressed.pdf uncompress
  3. Remove the watermark.

    bbe -e 's/(WATERMARK)Tm//' uncompressed.pdf > clean.pdf
  4. Compress the PDF.

    pdftk clean.pdf output outfile.pdf compress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment