Rails Prawn を使用して pdf ファイルを生成しています。これで、必要なもの (テーブル、ヘッダー、フッター、ロゴ、ボーダーなど) をすべて含む pdf を生成できるようになりました。別のモジュール内のメソッドで共通のもの (ヘッダー、フッター、ボーダー) を使用し、元のプログラムからこのメソッドを呼び出す必要がありますか?
私のオリジナルプログラム: travel_report.rb モジュール TravelReport
include Header def self.generate(start_ts, end_ts, format_type, obu_ids, interval) Prawn::Document.generate("public/test.pdf") do
国境
page_count.times do |i|
go_to_page(i+1)
Header.border
end
ヘッダーと境界線
page_count.times do |i|
go_to_page(i+1)
ask = "public/ashok.jpg"
image ask, :at => [15, 750], :width => 120
alert = "public/alert.jpg"
image alert, :at => [410, 740], :width => 120
end
フッター
page_count.times do |i|
go_to_page(i+1)
lazy_bounding_box([bounds.left+30, bounds.bottom + 20], :width => 100) {
text "Bypass Report"
}.draw
end
end
Borders 用の別のモジュール module Header #class Cheader < Prawn::Document::BoundingBox #include Prawn def self.border
pdf = Prawn::Document.new
pdf.bounding_box([5, 705], :width => 540, :height => 680) do
pdf.stroke_bounds
end
end
#end
終わり
このコードは境界線を作成しません...これのために別のモジュールを作成する方法はありますか????