fileList[i].getPasswordBytes());
pdfReader.removeUnusedObjects();
pdfReader.consolidateNamedDestinations();
int pdfNumberOfPages = pdfReader.getNumberOfPages();
PageRotation rotation = inputCommand.getRotation();
// rotate all
if (rotation.getType() == PageRotation.ALL_PAGES) {
int pageRotation = rotation.getDegrees();
LOG.debug("Applying rotation of " + pageRotation + " for all pages");
for (int j = 1; j <= pdfNumberOfPages; j++) {
PdfDictionary dictionary = pdfReader.getPageN(j);
int rotationDegrees = (pageRotation + pdfReader.getPageRotation(j)) % 360;
dictionary.put(PdfName.ROTATE, new PdfNumber(rotationDegrees));
}
} else if (rotation.getType() == PageRotation.ODD_PAGES) {
// odd pages rotation
int pageRotation = rotation.getDegrees();
LOG.debug("Applying rotation of " + pageRotation + " for odd pages");
for (int j = 1; j <= pdfNumberOfPages; j = j + 2) {
PdfDictionary dictionary = pdfReader.getPageN(j);
int rotationDegrees = (pageRotation + pdfReader.getPageRotation(j)) % 360;
dictionary.put(PdfName.ROTATE, new PdfNumber(rotationDegrees));
}
} else if (rotation.getType() == PageRotation.EVEN_PAGES) {
// even pages rotation
int pageRotation = rotation.getDegrees();
LOG.debug("Applying rotation of " + pageRotation + " for even pages");
for (int j = 2; j <= pdfNumberOfPages; j = j + 2) {
PdfDictionary dictionary = pdfReader.getPageN(j);
int rotationDegrees = (pageRotation + pdfReader.getPageRotation(j)) % 360;
dictionary.put(PdfName.ROTATE, new PdfNumber(rotationDegrees));