with File Paths

The easiest and most reliable way to merge PDF files, using the “GroupDocs.Merger for Java” product, is to use the full paths to these files.

The following example demonstrates how to merge PDF files using file paths in Java code:

There are situations, and quite often, when it is necessary to work with other classes inherited from java.io.InputStream, for example with FileInputStream or others. In this case, it is necessary to use additional parameters to specify the exact file type that is used in this case. Because the “GroupDocs.Merger for Java” product cannot always accurately determine the file type by its stream. Therefore, to avoid exceptions when merging PDF and other files, see the example below:

There may also be situations when it is necessary to combine different types of streams into PDF. In this case, you can use the example below: