collection = Arrays.toList(sources);
} else if (sources instanceof Collection) {
collection = (Collection<Object>) sources;
}
PDFMergerUtility merger = new PDFMergerUtility();
for (Object source : collection) {
InputStream inputStream = PDFBox.toInputStream(source);
merger.addSource(inputStream);
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
merger.setDestinationStream(bos);
merger.mergeDocuments();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
return new DocumentOutput(bis);
} catch (IOException e) {