Ruby on rails 将图像插入到Prawn生成的PDF时出现奇怪的边框
我在这个链接上有一个图像: 我正在尝试使用以下方法将此图像作为背景插入pdf:Ruby on rails 将图像插入到Prawn生成的PDF时出现奇怪的边框,ruby-on-rails,ruby,pdf,prawn,Ruby On Rails,Ruby,Pdf,Prawn,我在这个链接上有一个图像: 我正在尝试使用以下方法将此图像作为背景插入pdf: image_path = "..." #path to the image pdf = Prawn::Document.new pdf.image image_path, width: pdf.bounds.width, height: pdf.bounds.height pdf.render_file "test.png" 输出PDF位于以下链接: 问题是在PDF中,您可以在图像的顶部和底部看到灰色边框(如果看
image_path = "..." #path to the image
pdf = Prawn::Document.new
pdf.image image_path, width: pdf.bounds.width, height: pdf.bounds.height
pdf.render_file "test.png"
输出PDF位于以下链接:
问题是在PDF中,您可以在图像的顶部和底部看到灰色边框(如果看不到边框,请尝试放大/缩小,您将看到边框)
这是怎么回事?我认为图像可能有问题,但我不确定。我希望你们能有个更好的想法
提前谢谢 与其设置高度和宽度,不如尝试设置位置,让图像缩放到最适合可用空间(匹配高度、匹配宽度、匹配两者)?您可能会看到图像的某些伪影被拉伸到pdf区域(如果图像尺寸与pdf不完全匹配)
pdf.image image_path,
:position => :center,
:vposition => :center,
:fit => [pdf.bounds.width, pdf.bounds.height]