如何使用prawn更改现有pdf的方向?

时间:2022-03-01 21:11:27

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.

我有一个pdf文件。我想将其所有页面向右旋转90度。如何使用Prawn gem实现这一目标?当我尝试使用现有的pdf作为模板并尝试旋转它时,它不起作用。我徒劳地尝试了下面的事情。

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")

1 个解决方案

#1


2  

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

使用:page_layout而不是布局...对于mote信息,请按照本教程http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Document.html

#1


2  

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

使用:page_layout而不是布局...对于mote信息,请按照本教程http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Document.html