As a C# developer, you may need to combine two or more PDF files into a single PDF. In such cases, if you don’t want to print various PDF files like reports, receipts, etc. one by one then combine them into one document and print. In this article, I am covering how to merge PDF files using a REST API.

Merge Multiple PDF Files using a Rest API

The following topics shall be covered in this article:

File Merger REST API and .NET SDK

For merging files, I will be using the .NET SDK of GroupDocs.Merger Cloud API. It is a feature-rich and high-performance Cloud SDK used to merge several documents into one, split a single document into multiple documents. It offers functionality to reorder or replace document pages, change page orientation, manage document passwords and perform other manipulations easily for any supported file format. Currently, it also provides Java, PHP, Ruby, Android, and Node.js SDKs as its document merger family members for the Cloud API.

You can install GroupDocs.Merger-Cloud to your Visual Studio project from the NuGet Package manager or using the following command in the Package Manager console:

Install-Package GroupDocs.Merger-Cloud

You need to get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Add your Client ID and Client Secret in the code as demonstrated below:

Merge PDF Files using a REST API

You can combine two or more PDF files or merge specific pages of PDFs by following the simple steps mentioned below:

Upload the PDF Documents

Firstly, upload the PDF documents to the Cloud using any of the following methods:

  • Using the dashboard
  • Upload all files one by one using Upload File API from the browser
  • Upload programmatically using the code example given below:

As the result, PDF files will be uploaded to the Cloud Storage.

Combine Specific Pages from PDFs

Uploaded PDF files at dashboard.groupdocs.cloud/files

Merge the Uploaded PDF Files

This simple code example demonstrates how to merge multiple PDF files using a REST API into a single PDF.

Combine Specific Pages of a PDF File with another File

You may combine specific pages of a PDF file with another file. For this purpose, you need to provide a range of pages as demonstrated in the code example given below.

Download the Merged File

The above code sample will save the merged PDF file on the cloud. You can download it using the following code sample:

Conclusion

In this article, you have learned how to combine two or more PDF files or specific pages of PDF files on the cloud with .NET Merger REST API using C#. You also learned how to programmatically upload the files on the cloud and then download them from the cloud. You can learn more about GroupDocs.Merger Cloud API from the documentation. In case of any ambiguity, feel free to contact support.