PHP CupsPrintIPP usage

introduction

CupsPrintIPP is an extension of class library of PrintIPP. It implements operations which are not part of Internet Printing Protocol as described by RFCs.

It is built on CUPS-IPP-1.1 document.

response parsing

printer-type attribute

Cups adds an attribute named "printer-type" to printer's attributes.
Example:
                        
        echo "Printer attributes for printer $i:<pre>\n"; print_r($ipp->printer_attributes); echo "</pre>";
        if (isset($ipp->printer_attributes->printer_type->_value2)
                && ($ipp->printer_attributes->printer_type->_value2) == 'print-black')
            echo "The printer can print black<br />\n";
        if (isset($ipp->printer_attributes->printer_type->_value3)
                && ($ipp->printer_attributes->printer_type->_value3) == 'print-color')
            echo "The printer can print color<br />\n";

                        

functions reference

Operations

cupsGetDefault()

Get default printer attributes. Parsing is same as getPrinterAttributes() operation of standard PrintIPP class. Note that printer history is given as RFC3382 "collection", which needs a different handling.
Example:
        
        $ipp->cupsGetDefaults(array('all'));

        echo "</pre>\nPrinter historic for default printer:\n"; 

        $histo = $ipp->printer_attributes->printer_state_history->_value1;

        $idx_histo = "_indice0";
        for ($idx = 0 ; isset($histo->$idx_histo) ; $idx ++) {
        
            echo "<h3>next event:</h3>\n";
        
            foreach ($histo->$idx_histo as $key => $value) {
        
                if (is_object($value))
                    if ($key != 'printer_state_time') 
                        printf("%s: %s<br />",$key,$value->_value0);
                    else
                        printf("%s: %s<br />",$key,date('Y-m-d H:i:s',$value->_value0));

                $idx_key = "_key". ($key + 1);
            
                }
            
            $idx_histo = '_indice'. ($idx + 1);
            }

                        

cupsRejectJobs($printer_uri,$printer_state_message=false)

Causes CUPS rejecting jobs for given printer.

cupsAcceptJobs($printer_uri)

Causes CUPS accepting jobs for given printer.

cupsGetPrinters()

Alias for getPrinters().