ResizeProcessor resizer = new ResizeProcessor(resizeParameters);
RotateProcessor rotator = new RotateProcessor(rotateParameters);
WatermarkProcessor watermarker = new WatermarkProcessor(watermarkParameters);
try {
Document doc = new Document();
PdfWriter.getInstance(doc, new FileOutputStream(new File(applyFileNameMasks(outputPath, ((ImportedImage) model.get(0))))));
doc.open();
for(int i=0; i<modelSize; i++){
String filepath = ((ImportedImage) model.get(i)).getPath();
if(getExtension(filepath).equalsIgnoreCase("pdf")){
ArrayList<BufferedImage> extractedImages = (ArrayList<BufferedImage>) PDFToImage.getBImagesFromPDF(((ImportedImage) model.get(i)).getPath(), 1, Integer.MAX_VALUE);
for (BufferedImage currentImage : extractedImages) {
BufferedImage image = bufferedImageProcess(resizer, rotator, watermarker, currentImage);
image = bufferedImageProcess(resizer, rotator, watermarker, image);
addImageToPDDocument(doc, image);
}
} else {
BufferedImage image = Utils.loadImage(filepath);
image = bufferedImageProcess(resizer, rotator, watermarker, image);
addImageToPDDocument(doc, image);
}
progressBar.showProgress(((ImportedImage) model.get(i)).getPath());
progressBar.updateValue(true);
}
doc.close();
} catch (DocumentException ex) {
Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
}