Some test text!

Search
Hamburger Icon

Ruby / Guides / Rotate pages

Rotating a PDF page in Ruby

To rotate a page in a PDF document.

doc = PDFDoc.new(filename)

# Rotate the first page 90 degrees clockwise.
page = doc.GetPage(1)
originalRotation = page.GetRotation()
rotation = nil
if originalRotation == Page::E_0
  rotation = Page::E_90
elsif originalRotation == Page::E_90
  rotation = Page::E_180
elsif originalRotation == Page::E_180
  rotation = Page::E_270
elsif originalRotation == Page::E_270
  rotation = Page::E_0
else
  rotation = Page::E_0
end
page.SetRotation(rotation)

About rotating pages

A page can be rotated clockwise, by 90 degrees, when displayed or printed. The Page.GetRotation() method returns the Page.Rotate enum specifying the current rotation. Similarly, Page.SetRotation() sets the current rotation.

Get the answers you need: Chat with us