开发者

Line not rendering

开发者 https://www.devze.com 2023-04-04 11:20 出处:网络
I am developing some prawn reports and running into an issue where any line I draw with a code like the following will render only in the last page.

I am developing some prawn reports and running into an issue where any line I draw with a code like the following will render only in the last page.

horizontal_line(0, 200, :at => y)

It is called once per page.

My code is relatively complex now so I tried to isolate the problem to post here, the isolated code follows

require 'prawn'

a = Prawn::Document.new(:page_size => 'A4', :margin => [20,20,20,20])
a.font('Times-Roman')
a.horizontal_line(10, 400, :at => 开发者_StackOverflow社区140)
a.text_box('Test Text', :size => 50, :at => [2, 100], :width => 400)
puts a.render

For my surprise, it didn´t work even with a single page document. Only the "Test Text" is being rendered. It makes me think I am doing something wrong in the page setup or something like that.


Fond out the problem.

The correct use would be:

require 'prawn'

a = Prawn::Document.new(:page_size => 'A4', :margin => [20,20,20,20])
a.font('Times-Roman')
a.stroke do
  a.horizontal_line(10, 400, :at => 140)
end
a.text_box('Test Text', :size => 50, :at => [2, 100], :width => 400)
puts a.render
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号