English

Merge or split PDF, Word, Excel, PowerPoint files, eBooks, and images

High-performance file merging APIs for .NET and Java, enabling app developers to join PDF, merge Word files, spreadsheets, presentations, diagrams, eBooks, and image files. Extract, swap, rotate, or remove document pages, and merge JPG, PNG, or GIF images.

Try our APIs for FreeGet Temporary License

Feature-rich document merging and splitting solutions

Document merging is joining multiple documents into a unified file. You can merge documents and images to consolidate data and information into a centralized resource for collaboration and sharing. File merging is also used for combining different kinds of data into one document. For example, you could have a business requirement to use textual data from one document and graphic data from another document and present them in a marketing report by merging both sets of information.

Document splitting refers to dividing a single document into multiple files. Splitting a file could help generate various reports and presentations containing information from different data sets. It also makes sharing and downloading larger files easier in distributed environments, as they have been divided into smaller parts. Are you looking for a solution to split or merge documents and images in .NET and Java platforms? If yes, GroupDocs.Merger APIs for .NET and Java could be your ultimate choice. These APIs empower developers to build PDF merger apps, merge Word files, combine Excel and PowerPoint documents, diagrams, and eBooks, and merge JPG, PNG, GIF, and TIFF images.

Getting Started

To merge documents and images or start splitting them, please install the required version of GroupDocs.Merger (for .NET or Java) and all prerequisites to enjoy a seamless experience.

GroupDocs.Merger for .NET installation

Please download the MSI installer or DLLs from the download section, install the API via NuGet, or use the Package Manager Console to install GroupDocs.Merger for .NET:

PM> Install-Package GroupDocs.Merger 

For more help and information, please view the detailed installation guide.

GroupDocs.Merger for Java installation

For installing the Java version of GroupDocs.Merger API, you can either download the JAR file directly or use the latest configurations in your Maven applications in Java.

<repository>
    <id>groupdocs-artifacts-repository</id>
    <name>GroupDocs Artifacts Repository</name> <url>https://releases.groupdocs.com/java/repo/</url>
</repository>
<dependency>
    <groupId>com.groupdocs</groupId>
    <artifactId>groupdocs-merger</artifactId>
    <version>22.7</version>
</dependency>

Please view this guide for further help on installing GroupDocs.Merger for Java.

Document merging and splitting use cases

Upon successfully setting up GroupDocs.Merger for .NET or Java on your system, you can check some of the popular use cases for joining or splitting documents, and swapping, rotating, extracting, or deleting document pages.

Document merging and splitting use cases

Learn to merge PDF files in C# .NET and develop Java PDF merger apps

PDF files have become the standard for document sharing and storage, and we often need to merge PDF files for various reasons such as combining data from multiple PDF documents into one file for peer review. Or, to centralize the resources like graphs and tables contained within the documents found on the company intranet for easy reference. Whatever the case scenario may be, GroupDocs.Merger APIs for .NET and Java are loaded with the right tool sets for you to combine PDF files while also preserving the text and graphical contents of the source documents.

Learn to merge PDF files in C# .NET and develop Java PDF merger apps

Merge PDF documents into a single file in the .NET platform

It will only take a few lines of C# code to combine PDFs into one file as shown in the below sample:

  // Load the source PDF document
using (Merger merger = new Merger(@"c:\sample1.pdf"))
{
    // Add a PDF file to merge
    merger.Join(@"c:\sample2.pdf");
    // Merge both PDF files and save the result
    merger.Save(@"c:\merged.pdf");
} 

Along with combining PDF files, you also have the option to merge multiple files of DOC, PPT, and XLS formats into a PDF document. Please use the following C# code for this purpose:

using (Merger merger = new Merger(@"c:\document1.pdf"))
{
      // Add the multi-format documents to merge 
     merger.Join(@"c:\document2.doc");
    merger.Join(@"c:\document3.ppt");
    merger.Join(@"c:\document4.xls");

	// Merge all documents into a single PDF file 
	merger.Save(@"c:\merged.pdf");
}  

Effortlessly merge PDF files into a single document in Java

Joining more than one PDF file into a single document is simple in Java too as shown in the code below:

    // Load the source PDF document
Merger merger = new Merger("c:\sample1.pdf")
// Add another PDF document
merger.join("c:\sample2.pdf");
// Merge both PDF files and save the result
merger.save("c:\merged.pdf");  
Along with the PDF merger functionality, you can also merge documents of DOC, PPT, and XLS formats into a single PDF file in Java as demonstrated in the following code snippet:
        Merger merger = new Merger("c:\document1.pdf");
        {
            // Add the multi-format documents to merge
            merger.join("c:\document2.doc");
            merger.join("c:\document3.ppt");
            merger.join("c:\document4.xls");
          
            // Merge all documents into a single PDF file
            merger.save("c:\merged.pdf");
        } 

How to merge Word files, Excel spreadsheets, and PowerPoint presentations in .NET and Java?

Versatility and ease of use are two of the factors that make Microsoft Word, Excel, and PowerPoint so popular the world over. These software applications allow us to create different types of professional-looking documents easily. Word is great for creating text-based documents, Excel is perfect for storing and manipulating data, and PowerPoint is ideal for creating presentations. You can merge any of these file types using GroupDocs.Merger APIs for .NET and Java.

How to merge Word files, Excel spreadsheets, and PowerPoint presentations in .NET and Java?

Merge Word, Excel, and PowerPoint documents in .NET

You can merge Word DOCX files using the C# code shown below. It must also be noted that this code is generic and could be used to merge Excel and PowerPoint files too. The only difference will be replacing the document name and type. For example, ‘sample1.docx’, ‘sample2.docx’, and ‘merged.docx’ will have the document extension changed from DOCX to either XLSX or PPTX.

    // Load the source DOCX file
using (Merger merger = new Merger(@"c:\sample1.docx"))
{
    // Add another DOCX file to merge
    merger.Join(@"c:\sample2.docx");
    // Merge DOCX files and save the result
    merger.Save(@"c:\merged.docx");
}    

Another very useful feature of GroupDocs.Meger for .NET API is to combine pages from different files into one document based on the specified page number or ranges. The following C# code lets you achieve this:

        string filePath = @"c:\sample1.docx";
        string filePath2 = @"c:\sample2.docx";
        string filePathOut = @"c:\output\result.docx";
        
        JoinOptions joinOptions = new JoinOptions(1, 4, RangeMode.OddPages);
        
        using (Merger merger = new Merger(filePath, loadOptions))
        {
            merger.Join(filePath2, joinOptions);
            merger.Save(filePathOut);
        }           

Merging documents of other popular formats such as ODT, EPUB, TXT, TEX, and HTML is also supported. Please check this guide for more help.

Join word-processing, spreadsheet, and presentation files in Java

Just like in .NET, Java users can also merge Word files easily using the below-given sample code. This same DOCX merger code snippet could be used to merge Excel and PowerPoint documents as well. You only need to replace the file names and extensions when working with spreadsheets and presentation files. As in, please replace DOCX extension with XLSX or PPTX in this code.

    // Load the source DOCX file
Merger merger = new Merger("c:\sample1.docx")

// Add another DOCX file to merge
merger.join("c:\sample2.docx");
// Merge DOCX files and save the result
merger.save("c:\merged.docx"); 

GroupDocs.Merger for Java lets you merge pages of several documents into a single file. You can specify the pages you want to combine in the resulting document. Please use the below-given sample Java code for this purpose:


String filePath = "c:\sample.docx";
String filePath2 = "c:\sample2.docx";
String filePathOut = "c:\output\result.docx";
// Set the start and end page numbers in JoinOptions class.
JoinOptions joinOptions = new JoinOptions(1, 2);
// Merge selective pages using the join method
Merger merger = new Merger(filePath);
merger.join(filePath2 , joinOptions);
merger.save(filePathOut);  

For more information on merging files of other formats including OpenDocument, EPUB, TEX, TXT, and HTML in Java, please visit this guide.

Merging JPG, PNG, BMP, GIF, and TIFF images in .NET and Java

Merging or joining different raster image files such as PNG, JPG, TIFF, and others can be a good way to create unique visuals for various purposes. Merging images may also be used to combine multiple images into one larger image, create a photomontage, remove unwanted elements from an image, or even create a collage. If you are someone who works with images regularly, you can use GroupDocs.Merger APIs for merging raster images such as JPG, PNG, TIFF, and GIF.

Merging JPG, PNG, BMP, GIF, and TIFF images in .NET and Java

Combine JPG images in your .NET image merging apps

To combine JPG image files, please utilize the C# coding shown below. You can merge JPG images horizontally or vertically depending on your intended use:

// Load the source image file
using (Merger merger = new Merger(@"c:\sample1.jpg"))
{
    // Define image join options with horizontal join mode
    ImageJoinOptions joinOptions = new ImageJoinOptions(ImageJoinMode.Horizontal);
    // Add another image file to merge
    merger.Join(@"c:\sample2.jpg", joinOptions);
    // Define image join options with vertical join mode
    joinOptions = new ImageJoinOptions(ImageJoinMode.Vertical);
    // Add the next image file to merge
    merger.Join(@"c:\sample3.jpg", joinOptions);
    // Merge image files and save the result
    merger.Save(@"c:\merged.jpg");
} 

Similarly, you can combine PNG, GIF, and other image file formats in .NET.

How to merge JPG images easily in Java apps?

Please use the Java code snippet shared below for merging JPG image files. You have the option to merge images vertically or horizontally:

// Load the source image file
Merger merger = new Merger("c:\sample1.jpg")
// Define image join options with horizontal join mode
ImageJoinOptions joinOptions = new ImageJoinOptions(ImageJoinMode.Horizontal);
// Add another image file to merge
merger.join("c:\sample2.jpg", joinOptions);
// Define image join options with vertical join mode
joinOptions = new ImageJoinOptions(ImageJoinMode.Vertical);
// Add the next image file to merge
merger.join("c:\sample3.jpg", joinOptions);
// Merge image files and save the result
merger.save("c:\merged.jpg"); 

Along with JPG, you can also combine PNG and BMP images in Java.

How to split PDF files, Word, Excel, and PowerPoint documents in .NET and Java?

Splitting PDF files, Word, Excel, or PowerPoint documents can help you arrange various types of information in different files. It also promotes convenient data sharing, retrieval, collaboration, and document editing. GroupDocs.Merger APIs provide all the necessary tools to seamlessly split documents of different formats within your .NET and Java applications.

How to split PDF files, Word, Excel, and PowerPoint documents in .NET and Java?

Splitting PDF, DOCX, XLSX, and PPTX documents in .NET

You can split PDF, DOCX, XLSX, PPTX, and other data files in .NET based on various split options such as by exact page numbers, by starting and ending pages, with even/odd filters, and more. The following C# code lets you split a PDF document by specified page numbers. This will generate three separate documents containing one page each as defined in SplitOptions:

string filePath = @"c:\sample.pdf";
string filePathOut = @"c:\output\document_{0}.{1}";
// Define page numbers in SplitOptions
SplitOptions splitOptions = new SplitOptions(filePathOut, new int[] { 3, 6, 8 });
// Split the document based on the specified split options
using (Merger merger = new Merger(filePath))
{
     merger.Split(splitOptions);
}

You can similarly split your DOCX, XLSX, PPTX, and other documents using GroupDocs.Merger for .NET.

Splitting PDF, Word, Excel, and PowerPoint files in Java

The same options for splitting data files are available in Java too. You can make use of these options when splitting PDF files, Word, Excel, and PowerPoint documents like defining page numbers, specifying page ranges, and more. In the below-shared example, we will be using specific page numbers to split a PDF file into three, separate single paged documents:

String filePath = "document.pdf";
String filePathOut = "document\_{0}.{1}";
// Specify page numbers and split the file into multiple single-page documents.
SplitOptions splitOptions = new SplitOptions(filePathOut, new int\[\] { 3, 6, 8 });
Merger merger = new Merger(filePath);
merger.split(splitOptions); 

Feel free to split your Word, Excel, PowerPoint, and other documents in Java in the same manner.

Extract, rotate, swap, or remove document pages in your .NET and Java file merger apps

In addition to splitting or merging documents and images, GroupDocs.Merger APIs support many other features such as the ability to rotate, swap, extract, or delete pages in a document. These functionalities are included in both .NET and Java versions of GroupDocs.Merger libraries and you can refer to the below-given information to know more about how they work.

Extract, rotate, swap, or remove document pages in your .NET and Java file merger apps

Extract and rotate document pages in .NET

Please use the following C# code to extract specific pages from a source PDF document:

string filePath = @"c:\sample.pdf";
string filePathOut = @"c:\output\result.pdf";
// Resultant document will contain pages 1 and 4
ExtractOptions extractOptions = new ExtractOptions(new int[] { 1, 4 }); 
using (Merger merger = new Merger(filePath))
{
    merger.ExtractPages(extractOptions);
    merger.Save(filePathOut);
} 

And to rotate specific pages of a PDF document by 90, 180, or 270 degrees, please use this C# code. For checking other supported document operations, please visit this page:

string filePath = @"c:\sample.pdf";
string filePathOut = @"c:\output\result.pdf";

RotateOptions rotateOptions = new RotateOptions(RotateMode.Rotate180, new int[] { 2, 3, 6 });

using (Merger merger = new Merger(filePath))
{
    merger.RotatePages(rotateOptions);
    merger.Save(filePathOut);
} 

Swap or remove document pages in Java

To swap one document page with another, please use the Java code shown below:

String filePath = "c:\sample.pptx";
String filePathOut = "c:\output\result.pptx";
// Set page numbers to be swapped
int pageNumber1 = 3;
int pageNumber2 = 6;
// Define swap options based on the selected page numbers
SwapOptions swapOptions = new SwapOptions(pageNumber2, pageNumber1);
Merger merger = new Merger(filePath);        
merger.swapPages(swapOptions);
merger.save(filePathOut); 

For removing one or more document pages, please use the following sample Java code. To review other supported file operations, please check the relevant page here:

String filePath = "c:\sample.one";
String filePathOut = "c:\output\result.one";
// Define the pages to be removed
RemoveOptions removeOptions = new RemoveOptions(new int[] { 3, 5 });
// Process the page removal file operation
Merger merger = new Merger(filePath);

merger.removePages(removeOptions);
merger.save(filePathOut);  

We also provide Free Online Apps to split or merge PDF, DOCX, XLXS, PPTX, and EPUB files. Please be sure to try the free apps if you are looking to merge Word to PDF, Excel to PDF, PowerPoint to PDF, merge JPG, PNG, BMP, and many other data files.

Looking for help?

Checkout our support channels for help with your questions related to Conholdate product API features and working.