GroupDocs.Merger for Node.js via Java

Rearrange pages in PDF

GroupDocs.Merger for Node.js via Java provides Node.js applications with the ability to easily change the order of pages in PDF documents.

How to rearrange PDF pages

GroupDocs.Merger simplifies the process of moving pages within PDF documents. Enhance your Node.js via Java applications with advanced document organization capabilities.

  1. Specify the path to the PDF document.
  2. Indicate the page number and its new position.
  3. Perform the page move operation.
  4. Save the modified document.
const mergerLib = require('@groupdocs/groupdocs.merger')

// Initialize a Merger instance with the source document
const merger = new mergerLib.Merger("document.pdf")

// Define the page number that needs to be moved
const pageNum = 3
const moveTo = 1
const moveOptions = new mergerLib.MoveOptions(pageNum, moveTo)

// Reposition the selected page
merger.movePage(moveOptions)

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

Comprehensive document handling

GroupDocs.Merger for Node.js via Java delivers a rich set of features, allowing you to work with over 50 popular business file formats efficiently.

Key capabilities of GroupDocs.Merger

Merge documents of different types

Combine content from PDFs, Word files, presentations, spreadsheets, images, and archives. Use flexible options to customize the final document structure.

Modify document pages

Rearrange pages in your documents by moving, swapping, or removing them as needed.

Adjust page layout and orientation

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

Extract pages as separate documents

Select specific pages and save them as standalone files for further use.

Move a page to the last position in a document

This example demonstrates how to relocate a page to the end of a PDF document.

JavaScript

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

// Provide the source document path
const merger = new mergerLib.Merger("document.pdf")

// Retrieve document details and determine the last page number
const info = merger.getDocumentInfo()
const pageNum = 1
const moveTo = info.getPageCount()

// Configure the move operation with the target page numbers
const moveOptions = new mergerLib.MoveOptions(pageNum, moveTo)

// Execute the move operation
merger.movePage(moveOptions)

// Save the updated document in the desired location
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 robust document processing tool supporting over 50 file formats, including PDF, Word, Excel, PowerPoint, images, and archives. It offers powerful features for merging, splitting, extracting, rearranging, swapping, and deleting pages.
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.

Core features

Discover other essential features included in our solution.

Rearrange pages in multiple formats

GroupDocs.Merger supports over 50 file formats, offering flexibility and precision in document manipulation.

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