Hi Team,
We use Groupdocs PDF Merge funtionality. In that, When you try to merge two PDF’s (3.2 MB & 9 KB),
Scenario 1:
If the first PDF is 3.2 MB and the Second PDF is 9 KB, the Outcome is doubling the Size as 6.4 MB
Scenario 2:
On the Other hand, If the first PDF is 9 KB and the Second PDF is 3.2 MB, then it is coming correctly as 3.2 MB
Attached PDF’s for your reference
(Not able to upload the 6.4 MB file (It is not allowing to upload file more than 4 MB)
So uploaded Pic)
Screenshot 2026-04-01 at 12.04.57 PM.jpg (284.4 KB)
)
File 1.pdf (3.0 MB)
File 2.pdf (8.8 KB)
Merged Document Scenario 2.pdf (3.1 MB)
Hello @akashkrishnan ,
Thank you for contacting us. Could you please clarify which GroupDocs product you are using? Is it GroupDocs.Merger for Java, or are you using the merging functionality via GroupDocs.Total for Java? We noticed that this request was created under the Conversion for Java category, so we would like to clarify this to avoid any confusion.
Also, could you please provide a code example you used to merge the two PDF files so that we can reproduce the issue exactly on our side?
@evgen.efimov
we are using GroupDocs.Merger for Java version 25.7.1
Here is the sample code
public void merge(@RequestParam String orgId, @RequestParam String file1, @RequestParam String file2) {
try {
// Apply license
try (InputStream isLic = Files.newInputStream(new File(licensePath).toPath())) {
License license = new License();
license.setLicense(isLic);
}
String mergedFile = String.format("output.pdf"); //Give path for output file
String file1S = String.format("file1.pdf"); //Give path for file1
String file2S = String.format("file2.pdf"); //Give path for file2
mergePdfs(file1S, file2S, mergedFile);
} catch (Exception e) {
e.printStackTrace();
}
}
static void mergePdfs(String file1, String file2, String outputPath) throws Exception {
InputStream firstPdfInputStream = new FileInputStream(file1);
// Create GroupDocs Merger instance with the first PDF
Merger merger = new Merger(firstPdfInputStream);
InputStream secondPdfInputStream = new FileInputStream(file2);
// Join second PDF
merger.join(secondPdfInputStream, new JoinOptions());
// Save directly to file (this is what you want)
merger.save(outputPath);
// Close streams
secondPdfInputStream.close();
firstPdfInputStream.close();
}
Sorry for the delay. We are continuing to investigate the issue. We will update you as soon as we have new information.
Hello,
Thank you for reporting this issue. We have investigated it and confirmed the behavior you described.
Root cause: During the PDF merge process, the first document was used as a base for the resulting file. Although its pages were cleared before re-adding, the internal PDF objects (fonts, images, XObjects, and other indirect objects) remained orphaned in the document’s cross-reference table. When pages from the same document were then re-imported, all those resources were duplicated in the output — once as orphans from the original base, and once as freshly imported copies. This is why the output size roughly doubled when the larger file was passed first.
Fix: The merge logic has been updated to use a new empty PDF document as the base, so all source documents are now processed uniformly without inheriting any orphaned objects. The output file size is now correct regardless of the order of input documents.
This fix is available starting from GroupDocs.Merger for Java 26.4.
Please update to the latest version and let us know if you have any further questions.
Thank you.
Hello @AlekseiSemenchenko I don’t see Groupdocx.Merger for Java 26.4 yet in the Groupdocs releases. Can you please let us know by when this will be available?
Thank you for bringing this to our attention, we have updated the information. The library in the repository was already available from the start.