Skip to content

Instantly share code, notes, and snippets.

Last active May 5, 2022 02:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Fix cups-pdf not printing PDFs with restrictions

Fix problem when cups-pdf (actually Ghostscript) refuses to print PDF files with restrictions

Specifically, even if the file has no printing restrictions, like many government forms do (my specific itch), Ghostscript refuses to print the file and generates a blank pdf.

Steps to fix

  1. Put contents of in an executable file named /usr/lib/cups/filter/unblockprint. Make sure that the permissions of this file matches others in the same directory.
  2. Put local.convs in /etc/cups
  3. Restart cups service.
application/postscript application/vnd.cups-postscript 60 unblockprint
# unblockprint - Removes comment blocking PDF printing
echo "DEBUG: unblockprint argv[$#] = $@" >&2
if [ $# -lt 5 -o $# -gt 6 ]; then
echo "ERROR: $0 job-id user title copies options [file]" >&2
exit 1
# Read from given file.
if [ -n "$6" ]; then
exec <"$6"
sed -e '/eleven lines/,+11d' | $CUPS_SERVERBIN/filter/pstops "$1" "$2" "$3" "$4" "$5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment