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.

Install Open Source Feather Icons

Create WhatsApp clone with Next.js Part 7 Sidebar notification

Policies made easy by aex middlewares with fallback

AWS Amplify for React/React Native Development — Pt 1 Setting up your Amplify Environment

An Overview of Next-Generation JavaScript Features for React Apps

Managing ALM integrations in SonarQube via PostMan(Azure DevOps) with example code in

An Introduction to Webpack

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

Why spring boot is the famous framework for developing REST APIs in Java

Build maven project with push to docker hub in same time

AWS EC2 with Spring Boot Java — Part 1

Experience with Spring batch and docker