Class MergeUtil


  • public class MergeUtil
    extends Object
    Deprecated.
    Merge functionality may be removed in a future PDFxStream release

    A PDF file merge utility.

    This utility supports merging any number of PDF files into a single PDF document. Metadata, annotations, bookmarks, and form data that might be found in the given source PDF files are not transferred to the merged PDF file.

    Since:
    2.0
    Version:
    ©2004-2024 Snowtide
    • Method Detail

      • mergeDocuments

        public static void mergeDocuments​(File[] pdfFiles,
                                          File destFile)
                                   throws IOException
        Deprecated.
        Merges a series of PDF files into a single PDF document, and writes the merged document data to the given file path.
        Parameters:
        pdfFiles - an array of File references to the PDF files to be merged, in the order their content should appear in the resulting merged PDF document
        destFile - a File reference where the merged PDF document is written
        Throws:
        IOException - thrown if an error occurs while merging the given list of PDF files
        See Also:
        mergeDocuments(File[], OutputStream)
      • mergeDocuments

        public static void mergeDocuments​(File[] pdfFiles,
                                          OutputStream destStream)
                                   throws IOException
        Deprecated.
        Merges a series of PDF files into a single PDF document, and writes the merged document data to the given OutputStream.
        Parameters:
        pdfFiles - an array of File references to the PDF files to be merged, in the order their content should appear in the resulting merged PDF document
        destStream - an OutputStream to which the merged PDF document data is written
        Throws:
        IOException - thrown if an error occurs while merging the given list of PDF files
      • main

        public static void main​(String[] args)
        Deprecated.
        Command-line usage of this class may be moved or removed in future PDFxStream releases.

        Command-line interface to PDF merge functionality.

        Usage:

        java -cp PDFxStream.jar com.snowtide.pdf.util.MergeUtil [src_pdf1] [src_pdf2] ... [src_pdfN] [dest_path]

        Any number of paths to source PDF documents may be passed as arguments to this utility; the last argument provided is assumed to be the desired destination path of the merged PDF file

        Example:

        java -cp PDFxStream.jar com.snowtide.pdf.util.MergeUtil ~/folder/report1.pdf ~/index.pdf result.pdf


        This will merge the PDF files 'report1.pdf' and 'index.pdf', in that order, and write the result to 'result.pdf' in the current directory.