Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// For complete examples and data files, please go to
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.