Created
April 25, 2019 15:45
-
-
Save GroupDocsGists/17c3111caf511725760bbd3db43beee3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/GroupDocs-Merger/GroupDocs.Merger-for-Java | |
String sourceFile = CommonUtilities.sourcePath + fileName; | |
// Preparing. | |
String password = "SomePasswordString"; | |
int pageNumber1 = 3; | |
int pageNumber2 = 6; | |
SwapOptions pagesOptions = new SwapOptions(pageNumber2, pageNumber1, FileFormat.One, password); | |
InputStream documentExample = new FileInputStream(sourceFile); | |
// Main method. | |
DocumentResult result = new DocumentHandler().swapPages(documentExample, pagesOptions); | |
OutputStream documentStream = result.getStream(); | |
ByteArrayOutputStream byteArrayStream = (ByteArrayOutputStream) documentStream; | |
byte[] bytes = byteArrayStream.toByteArray(); | |
FileOutputStream fos = new FileOutputStream(CommonUtilities.outputPath + fileName); | |
fos.write(bytes, 0, bytes.length); | |
fos.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment