Maybe you need to set the cropBox as well.
Tilman
Am 16.01.2022 um 14:29 schrieb Dip Narayan Sarkar:
Hi,
Please see the sample code below:
In the final Output A_3.pdf , the page size does not change to A3.
Please let me know if I am missing something.
public static void main(String[] args) throws Exception {
PDFMergerUtility pdfMergerUtil = new PDFMergerUtility();
pdfMergerUtil.addSource("D:\\0PDFMERGE\\PDFBOX\\A.pdf");
pdfMergerUtil.addSource("D:\\0PDFMERGE\\PDFBOX\\C.pdf");
pdfMergerUtil.setDestinationFileName("D:\\0PDFMERGE\\PDFBOX\\AC_OUT.pdf");
pdfMergerUtil.mergeDocuments(null);
File mergedFile = new File("D:\\0PDFMERGE\\PDFBOX\\AC_OUT.pdf");
PDDocument doc = PDDocument.load(mergedFile);
for( PDPage page: doc.getPages()) {
page.setMediaBox(PDRectangle.A3);
}
doc.save("D:\\0PDFMERGE\\PDFBOX\\A_3.pdf");
doc.close();
}
Strange thing though, if I use A6 instead of A3 the page size does
change. Looks like the document generated by PDFMergerUtility sets
the MAX and does not allow to set beyond that , but allows shrinking
the size.
BR,
Dip
Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
Windows
---------------------------------------------------------------------
To unsubscribe, e-mail:users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail:users-h...@pdfbox.apache.org