Rearrange PDF Pages Using Java

Import JAR Dependency

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.pdf.free</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>

Sample Code

import com.spire.pdf.PdfDocument;

public class RearrangePages {

public static void main(String[] args) {

//Create a PdfDocument object
PdfDocument doc = new PdfDocument();

//Load the sample PDF file
doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\Food.pdf");

//Rearrange pages by setting a new page order
doc.getPages().reArrange(new int[]{0, 2, 1, 3});

//Save to file
doc.saveToFile("ChangeOrder.pdf");
doc.close();
}
}

--

--

--

Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

STAFI VALIDATOR ECOBUILDING PROJECT — THE PROGRAM DESIGNED ON STAFI FOR VALIDATOR INTEGRATION.

Parlor tricks with Kubernetes contexts

I made the transition from being a manual tester to an automated testing in just a space of three…

How To Upload Images With Cloudinary and MERN, Part 2

Writing Clean and Consistent Code with Static Analysis using PMD and Apex

Free Download High Performance MySQL: Optimization, Backups, and Replication Full-Online

Get my feet wet with Gradle

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Count the Number of Words in a Word Document Using Java

Java libraries (Java API)

Develop Bluetooth LE application easily with JAVA and BleuIO

How to run Eclipse MAT (Memory Analyzer Tool) on macOS