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>4.3.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

Exemplo de alternativa ao switch case no Typescript.

BEGINNER’S GUIDE TO DOM

How to Use IBM’s Carbon Design System (React) to Create a Quick UI

Explore espeak-ng Command in linux……..

TLDR: Angular Route Resolvers

Understanding Node.js for application development

Managing Azure DevOps Pats for technical users via NodeJs and PostMan

Create a Deno Rest API: A promising start with Alosaur and TypeORM

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

How to: Log4J2 and Graylog in a Spring Boot application

How to Merge Two Word DocX Documents Together using Java

FullStack Web Application—Springboot Project (Part 1: Back-end)

JAVA & Git-Hub