如何使用 Prawn(pdf 库)为图像添加边框?如果可以的话,你能添加填充吗?
最佳答案
您可以使用bounding_box和strike_bounds添加边框。在此示例中,我在图像周围添加了边框。我什至给它设置了 15 的 padding。将其设为一个函数应该相对容易,其中可以使用 padding 参数来计算图像宽度和bounding_box 宽度之间的差异。
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
关于ruby - 如何用 Prawn 为图像添加边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13389459/