Sha256: 3fc99d8e1eec8e8fbbd4ee079ac22716d18f9e86fbe624ddac16a6e9ac6ffa55
Contents?: true
Size: 1.58 KB
Versions: 6
Compression:
Stored size: 1.58 KB
Contents
class PdfPrinter < ActionPrinter #IKKE FÆRDIG def do_render(print_job,*args) # first we will call super to do the html thing html_path = super # # calls java -jar with the oxen_printer gem lib/java_pdf/barcodeprinter.jar - as in java -jar /Users/walther/Projects/Gems/oxen_printer/lib/java_pdf/barcodeprinter.jar $1 $2 var = %x[ bin/printer_cmd.sh #{html_path} #{pdf_file_path} ] logit :info, "converted the html file to a PDF file: #{pdf_file_path}" true rescue => e logit :error, "Rendering to PDF failed! The error was #{e.message}" false end def do_print copies, usr=nil result = nil prn = printer unless prn.command.blank? if prn.command=="email" prn.delete return super else pdf_path = pdf_file_path.split("/")[-1] pap = paper || prn.paper cmd = prn.command.gsub( /\$1/, prn.cups_printer ).gsub( /\$2/, pap ).gsub( /\$3/, pdf_file_path ).gsub( /\$4/, pdf_path ) if copies > 1 cmdargs = cmd.split(" ") f = cmdargs.pop cmdargs.push "-n", copies, f cmd = cmdargs.join(" ") end # Here we start actually printing # $1 is the CUPS printer # $2 is the PDF file_path_and_name # $3 is the PDF filename # the command being something along the lines of: lp -d $1 -o media=a4 $2 return `#{cmd}` end end rescue => e logit :error, "Printing failed! The error was #{e.message}" false end def file_path pdf_file_path end def get_file_type "application/pdf" end end
Version data entries
6 entries across 6 versions & 1 rubygems