# encoding: UTF-8 #/* - - - - - - - - - - - - - - - - - - - - - # # Title : WEB Appliances Crest Inc, Web Form Framework # Author : Enrique Phillips # URL : http://www.wac.bz # #- - - - - - - - - - - - - - - - - - - - - */ require 'action_printer' module PrintDrivers include Exceptions def self.included(base) # build PDF or somehow prepare printer output def rendered_on(*args) begin update_column(:state, "rendering") # TODO 2013-06-08 set the action_printer with respect to the selected output & printer action_printer = case print_driver when :pdf, "pdf" require 'oxen_printer/pdf_printer' PdfPrinter.new(printer, paper) when :cab, "cab" require 'oxen_printer/cab_printer' CabPrinter.new(printer, paper) when :label, "label" require 'oxen_printer/label_printer' LabelPrinter.new(printer, paper) when :html, "html" require 'oxen_printer/html_printer' HtmlPrinter.new(printer, paper) when :csv, "csv" require 'oxen_printer/csv_printer' CsvPrinter.new(printer, paper) end rescue => e logit :error, "assigning printer driver failed - #{e.message}" return nil end # print_job.action_printer.printer = print_job.printer # print_job.cycle if return action_printer if action_printer.do_render(self,args) nil end # # called from the perform on the print_job # print_with will use the action_printer to build the print # and return the resulting filepath # def print_with action_printer update_column(:state, "printing") if action_printer && action_printer.do_print(copies,printed_by_id) update_column(:state, 'done') action_printer.file_path else update_column(:state, 'error printing') raise PrintJobPrintingError end end def send_with action_printer, context begin update_column(:state, 'sending') if action_printer && action_printer.send_print_file( context) update_column(:state, 'done') action_printer.file_path else update_column(:state, 'error sending') raise PrintJobPrintingError end rescue => e end end # q%{ # Problem with CUPS printer definitions - losing knowledge of attached printers # # D [08/Dec/2008:16:20:25 +0100] cupsdAuthorize: No authentication data provided. # D [08/Dec/2008:16:20:25 +0100] Print-Job ipp://localhost/printers/HP_LaserJet_M3035_MPF_192.168.105.78 # D [08/Dec/2008:16:20:25 +0100] print_job: auto-typing file... # D [08/Dec/2008:16:20:25 +0100] print_job: request file type is application/pdf. # D [08/Dec/2008:16:20:25 +0100] Print-Job client-error-not-found: The printer or class was not found. # D [08/Dec/2008:16:20:25 +0100] cupsdProcessIPPRequest: 8 status_code=406 (client-error-not-found) # D [08/Dec/2008:16:20:25 +0100] cupsdCloseClient: 8 # # } end end