Skip to content

Instantly share code, notes, and snippets.

@ricardodeazambuja
Last active February 5, 2022 21:13
Show Gist options
  • Select an option

  • Save ricardodeazambuja/6fc658f6f3cf8024bc102485883c0968 to your computer and use it in GitHub Desktop.

Select an option

Save ricardodeazambuja/6fc658f6f3cf8024bc102485883c0968 to your computer and use it in GitHub Desktop.
When your black cartridge is empty and your printer driver doesn't help, change the pdf from black to something else :D
#!/bin/bash
# From https://www.reddit.com/r/linux4noobs/comments/2yzld7/command_line_change_text_color_in_pdf/
# It will go through all the pdfs in the directory and change the color black (0 0 0) to something else (0.3 0.3 0.3)
# The RGB values here go from 0 to 1 instead of 0 to 255 ;)
for f in *.pdf; do
echo $f
pdftk "$f" output "tmp-$f" uncompress
sed -i "s/0 0 0 rg/0.3 0.3 0.3 rg/g" "tmp-$f"
sed -i "s/0 0 0 RG/0.3 0.3 0.3 RG/g" "tmp-$f"
pdftk "tmp-$f" output "filled-$f" compress
rm "tmp-$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment