ページごとに個別のユーザーpdfというアクションがあり、データベースから情報を取得するユーザーモデルの2つのモデルと通信しますがすべてのユーザーのための特定の情報のみを取得すると、情報を取得してモデルレポートに送信します。モデルユーザーから呼び出されていない方法で表示される各ユーザーの属性を調べると、別の順序でそれを配置するので、私はそれが悪い、イニシャルが私のテーブルの最後のレコードかもしれないと、携帯電話が最初のものかもしれない..私は、PDF上のテーブルに情報を書き込むと私は新しい各ユーザーの情報に関するページ。テーブル内のpdfに印刷する前に、ハッシュの値を並べ替える方法
私のレポートコードのようなもの:
def self.generate_individual_pdf(people,residents,user,estate = nil, title = nil)
pdf = PDF::Writer.new
title = !title ? "Report" :title
pdf.select_font "Times-Roman"
pdf.text "<em>Compiled By: #{user.presentation_name}</em> <em>Estate: #{estate.name}</em> <em>Created On: #{Time.now.strftime('%d/%m/%Y %H:%M')}</em>", :justification => :center
x = 0
25.times do
pdf.text ""+" "
x+=1
puts x
end
pdf.text "<em>User Report For: #{estate.name}</em> ", :font_size => 18, :bold => true, :justification => :center
if estate.logo
pdf.image "#{RAILS_ROOT}/public"+estate.logo.public_filename,:width => 100, :height => 100, :resize => 1.1, :justification => :center
end
y = 0
#loop people to create table for every person
people.each do |p|
pdf.start_new_page
pdf.text" "+p.Title.to_s+" "+p.Firstname.to_s+" "+p.Lastname.to_s, :font_size => 12, :justification => :center
pdf.text ""+" "
pdf.text ""+" "
pdf.text "Please verify if your details below are correct, and rectify them in the third column of the table.", :font_size => 8
pdf.text ""+" "
table = PDF::SimpleTable.new
table.column_order.push(*["head1","head2","head3"])
headings = ["head1","head2","head3"]
headings.each do |h|
table.columns[h] = PDF::SimpleTable::Column.new(h)
table.columns[h].heading = h.humanize
end
#display tables
table.show_headings = false
table.orientation = :right
table.position = :left
data = []
p.attributes.each_pair do |h|
data << { "head1" => h[0], "head2" => h[1], "head3" => " "}
end
table.data.replace data
table.render_on(pdf)
i = 0
28.times do
pdf.text ""+" "
i+=1
puts i
end
pdf.text "Kind Regards"+ " "+p.Title.to_s+" "+p.Firstname.to_s+" "+p.Lastname.to_s, :font_size => 11
pdf.text ""+" "
pdf.text "Signature "+"......................................."
end
それを行うp.attribute.each_pair throughtループするとき、それは出力を生成します| H | データ< < { "HEAD1" => H [0]、 "HEAD2" => H [1]、 "head3" => "これは nilをなければならない"} 端私がされている
ください人この種の並べ替えのすべてを使用しようとしているが、私はちょうど正しい答えを得ることはできません。
文は大文字で始まり、1つだけで終わり、 '.'文字で終わります。 –