GroupDocs.Merger for Node.js via Java

Page rotation in PDF

GroupDocs.Merger for Node.js via Java enhances Node.js applications by adding advanced document processing features. Rotate pages in PDF files and work with popular business formats effortlessly.

How to rotate PDF pages

With GroupDocs.Merger, you can easily rotate pages in PDF documents, adding powerful document management capabilities to Node.js via Java applications.

  1. Define the source path of the PDF file.
  2. Select the page number to rotate.
  3. Execute the page rotation operation.
  4. Save the modified file to your preferred location.
const mergerLib = require('@groupdocs/groupdocs.merger')

// Create an instance of Merger and load the source file
const merger = new mergerLib.Merger("document.pdf")

// Specify the page number to rotate
const rotateMode = mergerLib.RotateMode.Rotate180
const rotateOptions = new mergerLib.RotateOptions(rotateMode, 1, 1)

// Execute the page rotation operation
merger.rotatePages(rotateOptions)

// Save the output file to the desired location
merger.save("result.pdf")
npm i @groupdocs/groupdocs.merger
click to copy
copied
More examples Documentation

Powerful document content management

GroupDocs.Merger for Node.js via Java includes a wide range of features, enabling efficient processing of over 50 commonly used business file formats.

Key features of GroupDocs.Merger

Merge different file formats

Combine PDFs, Word documents, presentations, spreadsheets, Visio diagrams, images, and archives. Use various options for precise output.

Manage document pages

Rearrange pages by moving, swapping, or deleting them to structure your documents better.

Adjust page layout

Rotate pages to any angle or switch between portrait and landscape orientations.

Extract pages as separate files

Select a single page or a page range and save it as a new file in a chosen location.

Rotate all even-numbered PDF pages

This example demonstrates how to rotate all even-numbered pages in a PDF document.

JavaScript

const mergerLib = require('@groupdocs/groupdocs.merger')

// Load the source file into the constructor
const merger = new mergerLib.Merger("document.pdf");

// Get the total number of pages in the document
const info = merger.getDocumentInfo()
const lastPage = info.getPageCount()

// Configure rotation settings for even pages (180 degrees)
const rangeMode = mergerLib.RangeMode.EvenPages
const rotateMode = mergerLib.RotateMode.Rotate180
const rotateOptions = new mergerLib.RotateOptions(rotateMode, 1, lastPage, rangeMode)

// Apply the page rotation operation
merger.rotatePages(rotateOptions)

// Save the output file
merger.save("result.pdf")
npm i @groupdocs/groupdocs.merger
click to copy
copied
More examples Documentation

About GroupDocs.Merger

GroupDocs.Merger for Node.js via Java is a comprehensive document processing library that supports over 50 file formats, including PDF, Word, Excel, PowerPoint, Visio, images, and archives. It provides tools for merging, splitting, extracting, rearranging, and deleting pages, enhancing document handling in your applications.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Merger for free or get a trial license for full access!

Useful resources

Explore documentation, code samples, and community support to enhance your experience.

Key features

Explore the powerful features provided by our document processing library.

Rotate pages in multiple formats

GroupDocs.Merger supports over 50 file formats, allowing you to modify documents easily using a variety of operations.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English