だから私は私のレールでエビを使ってレポートを作成し、いくつかの会計データを作成します。モデルからではなく、file.pdf.prawn を作成し、そこにレポートのレイアウトを配置してエビを実行します。レポートの各ページの下部に小計が必要です。コントローラーから生成される all_total とは異なります。
つまり、1 ページに印刷されるデータの量を知る必要があり、そのデータを合計できます。
感謝と敬意
だから私は私のレールでエビを使ってレポートを作成し、いくつかの会計データを作成します。モデルからではなく、file.pdf.prawn を作成し、そこにレポートのレイアウトを配置してエビを実行します。レポートの各ページの下部に小計が必要です。コントローラーから生成される all_total とは異なります。
つまり、1 ページに印刷されるデータの量を知る必要があり、そのデータを合計できます。
感謝と敬意
行の高さが等しい場合は、紙に収まる行数を簡単にテストしてから、自分で数えることができます。
Table
行のサイズが等しくない場合は、Cell
クラスと同様に行のサイズを数えてみることができます。1 つの行を定義するための条件を追加するだけです。
# this code probably won't work because it's not tested
# I just typed it right here to show concept
module Prawn
class Cell
def custom_row_height(row_id)
each do |cell|
index = cell.send(:row)
if index == row_id do
result = cell.send(:height_ignoring_span)].compact.send(:max)
end
end
result
end
https://github.com/prawnpdf/prawn/blob/master/lib/prawn/table/cells.rbおよびhttps://github.com/prawnpdf/prawn/blob/master/lib/prawn/table/からのコードcell.rb :
module Prawn
class Cell
# Sum up a min/max value over rows or columns in the cells selected.
# Takes the min/max (per +aggregate+) of the result of sending +meth+ to
# each cell, grouped by +row_or_column+.
#
def aggregate_cell_values(row_or_column, meth, aggregate)
values = {}
each do |cell|
index = cell.send(row_or_column)
values[index] = [values[index], cell.send(meth)].compact.send(aggregate)
end
values.values.inject(0, &:+)
end
module Prawn
class Table
class Cell
# Returns the total height of all rows in the selected set.
def height
aggregate_cell_values(:row, :height_ignoring_span, :max)
end