package com.groupdocsdev.classes; import java.util.Arrays; import com.groupdocs.cloud.merger.client.*; import com.groupdocs.cloud.merger.model.*; import com.groupdocs.cloud.merger.model.requests.*; import com.groupdocs.cloud.merger.api.*; import com.groupdocs.cloud.merger.client.ApiException; // How to rearrange pages in PDF file using Java. public class App { public static void main(String[] args) { // Create an instance of the Pages API PagesApi apiInstance = new PagesApi(configuration); try { // Prepare the settings FileInfo fileInfo = new FileInfo(); fileInfo.setFilePath("java-testing/input-sample-file.pdf"); MoveOptions options = new MoveOptions(); options.setFileInfo(fileInfo); options.setOutputPath("java-testing/move-pages.pdf"); options.setPageNumber(1); options.setNewPageNumber(2); MoveRequest request = new MoveRequest(options); DocumentResult response = apiInstance.move(request); // Get output file path System.out.println("Output file path: " + response.getPath()); } catch (ApiException e) { System.err.println("Exception while calling FileApi:"); e.printStackTrace(); } } }