prawn:Prawn::Document#bounding_box

まんま

#!/usr/bin/env ruby

require "prawn"

pdf = Prawn::Document.new

pdf.bounding_box([100,500], :width => 100, :height => 300) do
  pdf.text "This text will flow in a very narrow box starting" +
    "from [100,500]. The pointer will then be moved to [100,200]" +
    "and return to the margin_box"
end

pdf.render_file(File.basename($0, ".rb") + ".pdf")


まんま

#!/usr/bin/env ruby

require "prawn"

pdf = Prawn::Document.new

#pdf.polygon [0,250], [0,0], [150,100]
#pdf.polygon [100,0], [150,100], [200,0]

#pdf.polygon [200,450], [200,200], [350,300]
#pdf.polygon [300,200], [350,300], [400,200]

pdf.bounding_box([200,450], :width => 200, :height => 250) do
  pdf.polygon [0,250], [0,0], [150,100]
  pdf.polygon [100,0], [150,100], [200,0]
end

pdf.stroke

pdf.render_file(File.basename($0, ".rb") + ".pdf")


まんま

#!/usr/bin/env ruby

require "prawn"

pdf = Prawn::Document.new

pdf.bounding_box([200,450], :width => 200, :height => 250) do
  pdf.bounding_box([50,200], :width => 50, :height => 50) do
    # a 50x50 bounding box that starts 50 pixels left and 50 pixels down
    # the parent bounding box.
    pdf.polygon [0,250], [0,0], [150,100]
  end
end 

pdf.stroke

pdf.render_file(File.basename($0, ".rb") + ".pdf")
  • マニュアルのソースコード領域が間違っているようだ
  • bounding_box が bouding_box になっているし〜


まんま

#!/usr/bin/env ruby

require "prawn"

pdf = Prawn::Document.new

pdf.canvas do
  pdf.bounding_box([200,450], :width => 200, :height => 250) do
    # positioned at 'real' (200,450)
    pdf.polygon [0,250], [0,0], [150,100]
  end
end

pdf.stroke

pdf.render_file(File.basename($0, ".rb") + ".pdf")

良く分かっていない〜