By @quakewang
http://prawn.majesticseacreature.com/
Ruby PDF生成方案
font_families["msyh"] = {
:normal => { :file => "#{FONTS_PATH}/msyh/msyh.ttf" },
:bold => { :file => "#{FONTS_PATH}/msyh/msyhbd.ttf" }
}
image "#{IMAGES_PATH}/left-quote.png", :position => 0, :vposition => :top
image "#{IMAGES_PATH}/right-quote.png", :position => bounds.width - 130, :vposition => :bottom
image(
open(url),
:fit => [bounds.width, bounds.height],
:vposition => :center,
:position => :center
)
text_box string,
:at => [0, cursor],
:width => bounds.width,
:height => 60,
:overflow => :shrink_to_fit,
:valign => :center,
:align => :center
text "The <color rgb='FF0000'>end</color>", :inline_format => true, :align => :center
outline.define do
page :title => trip_name, :destination => 1
data.each do |s|
section(s[:title], :destination => s[:page], :closed => false) do
s[:nodes].each do |n|
page :title => n[:title], :destination => n[:page]
end
end
end
end
顺带广告:蝉游记