私は海老RubyのPDFジェネレータで文書を作成しようとしているが、私は次のような問題に直面している:バウンディングボックス
私が何をしようとしている構造を示し、以下の画像。
そして、これは私がこれを達成しようとしている方法で、私の本当のシナリオを模倣しようとするサンプルコードです。 2.times
と(50.times.map { |i| i.to_s }.join("\n"))
は動的データを模倣しています。
require 'prawn'
class MyPdf
def self.to_pdf(*args)
new(*args).to_pdf
end
def to_pdf
pdf.move_down 200
2.times do
pdf.bounding_box(
[0, pdf.cursor],
width: pdf.bounds.width
) do
pdf.text (50.times.map { |i| i.to_s }.join("\n"))
pdf.stroke_bounds
end
end
pdf
end
def pdf
@pdf ||= Prawn::Document.new(page_size: 'A4')
end
end
しかし、ダイナミックバウンディングボックスの配置には多くの問題があります。
あなたの人々がまたはバウンディングボックスをせずにこれを達成する方法を知っていますか?