Class: PdfPrinter
- Inherits:
-
ActionPrinter
- Object
- ActionView::Base
- ActionPrinter
- PdfPrinter
- Defined in:
- lib/oxen_printer/pdf_printer.rb
Instance Attribute Summary
Attributes inherited from ActionPrinter
Instance Method Summary collapse
- #do_print(copies, usr = nil) ⇒ Object
-
#do_render(print_job, *args) ⇒ Object
IKKE FÆRDIG.
- #file_path ⇒ Object
- #get_file_type ⇒ Object
Methods inherited from ActionPrinter
#command, #html_file, #initialize, #label_file_path, #logit, #pdf_file_path, #render_string_in, #send_print_file, #text_file
Constructor Details
This class inherits a constructor from ActionPrinter
Instance Method Details
#do_print(copies, usr = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/oxen_printer/pdf_printer.rb', line 16 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.}" false end |
#do_render(print_job, *args) ⇒ Object
IKKE FÆRDIG
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/oxen_printer/pdf_printer.rb', line 3 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.}" false end |
#file_path ⇒ Object
46 47 48 |
# File 'lib/oxen_printer/pdf_printer.rb', line 46 def file_path pdf_file_path end |
#get_file_type ⇒ Object
50 51 52 |
# File 'lib/oxen_printer/pdf_printer.rb', line 50 def get_file_type "application/pdf" end |