I am merging PDF content using PDFMergerUtility
in Java.
PDFMergerUtility bundle= new PDFMergerUtility();
bundle.addSource(new ByteArrayInputStream(contentService.retrieveData(transaction1);
bundle.addSource(new ByteArrayInputStream(contentService.retrieveData(transaction2);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()
bundle.setDestinationStream(outputStream); // setting outputstream
bundle.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
return outputStream.toByteArray(); // returning result
But by default it is opening on the last page of PDF when I try to open the resultant PDF. I am not using PDocument for these as
these are entity based documents. Due to this unable to use this below method. Can you please suggest any approach to directly set the opened page number in PDFMergerUtility
.
PDPageXYZDestination destination = new PDPageXYZDestination();
destination .setPageNumber(num);
PDActionGoTo action = new PDActionGoTo();
action.setDestination(destination );
pdf.getDocumentCatalog().setOpenAction(action);