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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With