[cups.general] Restrict print job based on MIME type

Jerome Alet alet at librelogiciel.com
Tue Nov 7 12:42:48 PST 2006


Hi,

On Tue, Nov 07, 2006 at 06:50:35PM +0000, Ari Constancio wrote:
> 
> I'm looking for a simple (but no simpler :)) way to restrict print
> jobs based on MIME types.
> I need to prevent printing of specific types.

What I'd do :

  0 - Let's say your print queue is named "MyQueue"
      and its Device URI in CUPS is, for example,
      ipp://myprinter.example.com/printers/port1
  
  1 - Download and install Tea4CUPS from :
  
          http://www.pykota.com/software/tea4cups
          
      If you don't want to fork 25 bucks, download                
      it using subversion.
      
  2 - Modify tea4cups.conf and define something like this :
  
          --- CUT ---
          prehook_checkmime : /path/to/your/script.sh
          --- CUT ---
          
  3 - Create script.sh with content looking like :          
  
          --- CUT ---
          #! /bin/sh
          MIME=`/usr/bin/file --mime $TEADATAFILE | cut -f 2,2 -d " " | cut -f 1,1 -d \;`
          case "$MIME" in 
              *text/plain)
                  exit 0  
                  ;;
              *application/pdf)    
                  exit 0
                  ;;
              *)    
                  exit -1
                  ;;
          esac        
          --- CUT ---
          
  4 - Change the Device URI for MyQueue so that Tea4CUPS is used :
  
        lpadmin -p MyQueue -v tea4cups://ipp://myprinter.example.com/printers/port1
        
  5 - Print something.        
  
Only files of MIME type text/plain or application/pdf will be printed. All other
files will be silently ignored.

IMPORTANT : my shell script skills are very very bad, so maybe the shell
script above doesn't work. You're mostly on your own, it's YOUR script
after all :-)

hoping this helps anyway

bye

Jerome Alet





More information about the cups mailing list