Merge PDF is doubling the Size using GroupDocs PDF Merge

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();
    }