remove print handling from main

This commit is contained in:
John Bintz 2010-01-05 22:16:10 -05:00
parent 37c54970d5
commit 93a540f5c1

View File

@ -7,69 +7,6 @@ Dir[File.dirname(__FILE__) + "/classes/*.rb"].each do |file|
require file require file
end end
module PrintHandling
#
# calculate the page size in PPI
#
def calculate_page_size
if @config['dpi']
if @config['page_size']
case @config['page_size'].downcase
when "letter", "letter_portrait"
page_width = 8.5; page_height = 11
when "letter_landscape"
page_width = 11; page_height = 8.5
when "half_letter_landscape"
page_width = 5.5; page_height = 8.5
end
else
page_width = @config['page_width_inches']
page_height = @config['page_height_inches']
end
page_width *= @config['dpi']
page_height *= @config['dpi']
else
page_width = @config['page_width']
page_height = @config['page_height']
end
[ page_width, page_height ]
end
#
# align the provided image on a white page
#
def build_for_print(input, output, side = "none")
page_width, page_height = calculate_page_size
command = [
"-density #{config['dpi']}",
"-size #{page_width.to_i}x#{page_height.to_i}",
"xc:white"
]
case side
when "none"
command << "-gravity Center"
when "left"
command << "-gravity East"
when "right"
command << "-gravity West"
end
command << "-draw 'image Over 0,0 0,0 \"#{input}\"'"
if output[0,1] == "|"
command << output[1..-1]
else
command << "\"#{output}\""
end
convert(command)
end
end
class SVGToTempBitmap < InputFilter class SVGToTempBitmap < InputFilter
include PrintHandling include PrintHandling