Managing multiple files can quickly become overwhelming when dealing with reports, invoices, or academic materials. A PDF merger allows you to combine PDF and PDF documents into a single file, reducing clutter, making sharing easier, and ensuring information stays consolidated.

PDF Merger API

With the GroupDocs.Merger Cloud SDK for .NET, you can easily merge PDF documents programmatically. This SDK provides developers the ability to build scalable apps that can combine PDFs in just a few lines of code. To install:

NuGet\Install-Package GroupDocs.Merger-Cloud -Version 23.10.0

Next, obtain your API credentials (Client ID & Client Secret) by following this link.

Merge PDF Documents in C#

Here’s how to combine multiple PDF files in your C# application:

  1. Create an instance of Configuration class where we pass client credentials as arguments.
var configurations = new Configuration(clientId, clientSecret1);
  1. Initialize the DocumentApi while passing Configuration object as argument.
var newApiInstance = new DocumentApi(configurationSettings);
  1. CDefine the source PDF files and pages to be merged using JoinItem.
var item1 = new JoinItem
  1. Prepare a JoinRequest with JoinOptions.
var requestOutput = new JoinRequest(options);
  1. Call the API to merge PDF documents and save the output.
var response = newApiInstance.Join(requestOutput);
combine PDF files

Image:- A preview of merged PDF files.

Combine PDF Files with cURL

You can also concatenate PDF documents using and cURL. This is perfect for automation scenarios. This approach is particularly beneficial for automating document management tasks, as it allows for the quick and easy consolidation of multiple PDF files into a single document.

  1. Generate JWT token:
curl -v "https://api.groupdocs.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=b7efc309-156b-4496-9501-68197f85c25a&client_secret=985132b15703be48a4bdf897e6c05777" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
  1. Merge specific PDF pages:
curl -v "https://api.groupdocs.cloud/v1.0/merger/join" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"JoinItems\": [    {      \"FileInfo\": {        \"FilePath\": \"{sourceFile1}\",        \"StorageName\": \"internal\",      },      \"Pages\": [2,3],    },{      \"FileInfo\": {        \"FilePath\": \"{sourceFile2}\",        \"StorageName\": \"internal\",      },      \"StartPageNumber\": 2,      \"EndPageNumber\": 5    }  ],  \"OutputPath\": \"{resultantFile}\"}"

Replace:

  • sourceFile1 - first PDF file.
  • sourceFile2 - second PDF file.
  • resultantFile -resultant PDF file.
  • accessToken - JWT access token generated above.

Try Free PDF Merger App

Experience our free PDF Merger App to combine PDF files online without installing any software.

pdf merger

Conclusion

Using GroupDocs.Merger Cloud SDK for .NET or cURL commands, you can merge all PDFs into one document quickly and securely. The SDK is ideal for developers who need integration in C# projects, while cURL offers a lightweight option for scripts and automation. Whether you want to combine PDFs, concatenate PDF documents, or explore an Adobe merge PDF alternative, GroupDocs provides the flexibility to meet your document management needs.

We recommend visiting the following links to learn more about: