Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the orientation of existing pdf using prawn?

Tags:

ruby

pdf

prawn

I have a pdf file. I want to rotate all of its pages 90 degrees to the right. How can I achieve this using Prawn gem? When I try to use an existing pdf as a template and try rotate on it, it does not work. I tried the following in vain.

require 'prawn/core'
require 'prawn/layout'
require 'prawn/measurement_extensions'

pdf = Prawn::Document.new(:page_size => [4.in, 6.in], :template => 'orig.pdf', :layout => 'potrait') do |p|
p.rotate(90)
end
pdf.render_file("./test1.pdf")

pdf = Prawn::Document.new(:page_size => [4.in, 6.in], :template => 'orig.pdf', :layout => 'potrait', :rotate => 90)
pdf.render_file("./test2.pdf")
like image 469
dknight Avatar asked Jul 29 '13 10:07

dknight


1 Answers

use :page_layout instead of layout... for mote info please follow this tutorial http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Document.html

like image 146
HarsHarI Avatar answered Nov 12 '22 22:11

HarsHarI