Ricardo Acras
Ricardo Acras

Reputation: 36244

Line not rendering

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 => 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.

Upvotes: 1

Views: 219

Answers (1)

Ricardo Acras
Ricardo Acras

Reputation: 36244

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

Upvotes: 2

Related Questions