Created
April 26, 2010 22:35
-
-
Save jkriss/380047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'prawn' | |
require 'prawn/measurement_extensions' | |
require 'RMagick' | |
show_name = ARGV[0] | |
output_name = ARGV[1] | |
Prawn::Document.generate("#{output_name}.pdf", :page_size => [11.in, 17.in], :left_margin => 0, :top_margin => 0, :right_margin => 0, :bottom_margin => 0) do | |
background = File.join(File.dirname(__FILE__),'assets/poster-background.jpg') | |
image background, :at => [0,17.in], :fit => [11.in,17.in] | |
font(File.join(File.dirname(__FILE__), '../fonts/FFF-Tusj.ttf')) | |
name_size = 150 | |
bounding_box [0.5.in,16.in], :width => 10.in, :height => 12.in do | |
font_size name_size | |
words = show_name.split(" ") | |
while words.collect{ |w| width_of(w) }.max > 10.in | |
name_size -= 10 | |
font_size name_size | |
end | |
if words.length == 1 | |
# there's a bug with the valign, so we do this... | |
text_box "\n\n"+show_name, :align => :center, :overflow => :shrink_to_fit | |
else | |
text_box show_name, :align => :center, :valign => :center, :overflow => :shrink_to_fit | |
end | |
end | |
end | |
img = Magick::Image::read("#{output_name}.pdf").first | |
img.write("#{output_name}.jpg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment