class QueueNoPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings, queue) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i self.item_font_size = printer_settings.item_font_size.to_i self.margin = 5 self.price_width = 35 self.qty_width = 20 self.total_width = 35 self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) self.item_height = 15 self.item_description_width = (self.page_width-20) / 2 self.label_width = 100 super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { :normal => "public/fonts/#{printer_settings.font}.ttf", :italic => "public/fonts/#{printer_settings.font}.ttf", :bold => "public/fonts/#{printer_settings.font}.ttf", :bold_italic => "public/fonts/#{printer_settings.font}.ttf" }) font "#{printer_settings.font}" fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end header( "Beauty In the Pot", printer_settings.name) queue_no(queue) stroke_horizontal_rule date_info(queue) end def header (printer_name, name) text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center text "#{name}", :size => self.header_font_size,:align => :center # move_down self.item_height move_down 5 stroke_horizontal_rule move_down 5 end def queue_no (queue) move_down 5 text "#{queue.queue_no}", :size => 100,:align => :center end def date_info(queue) move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "Date:", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.item_width) do text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left end move_down 5 end end