Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prawn doesn't draw a horizontal rule

I want to draw a simple horizontal rule. What I'm doing is:

move_down 30
horizontal_rule

and Gemfile

gem 'prawn', :git => "https://github.com/prawnpdf/prawn.git", branch: 'master' 

It doesn't draw anything.

like image 396
Alan Coromano Avatar asked Sep 29 '13 01:09

Alan Coromano


People also ask

What is prawn_document in prawnrails?

It provides a helper called prawn_document which builds a PrawnRails::Document with default options. You can override any options as you please. Example: No need to call pdf.render, it is called by prawn_document.

What is the data argument in prawn text drawing?

The data argument is a two dimensional array of strings, organized by row, e.g. [ [“ r1-col1”,“r1-col2”], ]. As with all Prawn text drawing operations, strings must be UTF-8 encoded.

How to use prawn and prawn-table in a Gemfile?

Note: prawn and prawn-table are dependencies of prawn-rails so there is no need to mention it in the projects Gemfile unless you want to use a specific version of either of those libraries. Create a view with pdf as format and prawn as handler so filename should look like example.pdf.prawn.

Can prawn-rails override the header of a file?

If you've already set this, prawn-rails will not override it. Here's an example of setting the header directly: You can also override the file's name from the controller via @filename: If no options are given, the file's name will match to your browser's default and the delivery format will default to inline.


1 Answers

You need to call horizontal_rule inside a stroke do block, i.e.

stroke do
  move_down 30
  horizontal_rule
end

Alternatively you can call the method, stroke_horizontal_rule.

move_down 30    
stroke_horizontal_rule

If you want to use other options such as color, width etc I think you have to do it in the block...

stroke do
  stroke_color 'ff0000'
  dash(5, space: 2, phase: 0)
  line_width 10
  stroke_horizontal_rule
  move_down 15
  horizontal_line(0, 540)
end
like image 119
Helios de Guerra Avatar answered Nov 10 '22 08:11

Helios de Guerra