In the latest release of our PDF library JPedal, we added some new features to our PDF merging tool. These new settings allow for greater control over the output when merging two or more PDF files.
How to use each new feature
First, you will need to create a list of MergeOptions and add each option to the list.
final ArrayList<MergeOption> options = new ArrayList<>();
options.add(MergeOption.INTERLEAVE);
Then you can call PdfMerge.mergeFiles() and pass the options list.
PdfMerge.mergeFiles(new File[] {new File("inputFile1.pdf"), …}, new File("outputFile.pdf"), options);
Add a dividing page
To add a blank page in between each input document, you can use MergeOption.ADD_DIVIDING_PAGE.
To add a footer to all pages which includes the original filename and page number, you can use MergeOption.ADD_FOOTER.
You can customise the appearance of the footer using PdfMergeAttributes.
Interleave
To merge documents by alternating pages from each input document, you can use MergeOption.INTERLEAVE.
Learn more about interleave merging.
Normalize page size
To ensure all pages in the output document are the same dimensions as the first page, you can use MergeOption.NORMALISE_PAGE_SIZE_TO_MATCH_FIRST.
Normalize page rotation
To ensure all pages in the output document have the same orientation as the first page, you can use MergeOption.NORMALISE_ROTATION_TO_MATCH_FIRST.
Download JPedal to get started
Download a JPedal jar from our website to instantly start merging PDF files.
Resources
Learn more about how to merge PDFs in Java.
We can help you better understand the PDF format as developers who have been working with the format for more than 2 decades!