Skip to content

Instantly share code, notes, and snippets.

@romuloceccon
Created July 20, 2011 23:07
Show Gist options
  • Save romuloceccon/1096148 to your computer and use it in GitHub Desktop.
Save romuloceccon/1096148 to your computer and use it in GitHub Desktop.
Rotation example with prawn
require 'rubygems'
require 'prawn'
$pdf = Prawn::Document.new(:page_size => 'A4')
$pdf.line_width = 0.3
def test_box(origin, angle)
$pdf.translate(*origin) do
$pdf.rotate(angle, :origin => [0, 0]) do
$pdf.stroke do
$pdf.rectangle([0, 0], 200, 40)
$pdf.horizontal_line(0, 200, :at => -20)
$pdf.vertical_line(0, -40, :at => 100)
$pdf.text_box('Romulo', :size => 20, :at => [0, 0], :width => 200, :height => 40,
:align => :center, :valign => :center)
end
end
end
end
test_box([0, 600], 45)
test_box([0, 600], 0)
test_box([250, 600], 90)
test_box([0, 500], 0)
test_box([250, 500], -45)
$pdf.render_file('a.pdf')
`cmd.exe /c start a.pdf`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment