2012-11-14 36 views

回答

2

您可以使用bounding_box和stroke_bounds添加边框。在这个例子中,我在图像周围放置了一个边框。我甚至给它填充了15个。使用padding参数来计算图像宽度和boundingbox宽度之间的差异的功能应该相对容易。

require 'prawn' 

Prawn::Document.generate("test.pdf") do 
    text "Boxed Image", :align=>:center, :size=>20 
    bounding_box([0, cursor], :width => 330) do 
     move_down 15 
     image "image.jpg", :fit => [300, 600], :position => :center 
     move_down 15 
     stroke_bounds 
    end 
end 
+0

这样做了,谢谢!很好的答案。 – vramon

相关问题