Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active June 17, 2024 13:41
Show Gist options
  • Save groupdocs-cloud-gists/b28d0bcb4006be0126f975dd4f61e17a to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/b28d0bcb4006be0126f975dd4f61e17a to your computer and use it in GitHub Desktop.
Combine PDF Files with PDF Merger

Combine PDF files with .NET REST API


Combining PDF files into a single document using C# .NET streamlines document management and enhances productivity. Whether you're consolidating reports, merging contracts, or organizing educational materials, this feature enables us to store documents for long term archival. The PDF merge operation is accomplished using GroupDocs.Merger Cloud SDK .Net.



For more details, please visit Combine PDF Files with PDF Merger.

combine PDF files

Important Links

Product Page | Docs | Live Demo | API Reference | Code Samples | Source Code | New Releases | Blog | Free Support | Free Trial

How to merge PDF files with .NET REST API.
// More examples over https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-dotnet
// Obtain your API credentials
string clientId = "b7efc309-156b-4496-9501-68197f85c25a";
string clientSecret1 = "985132b15703be48a4bdf897e6c05777";
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret.
var configurationSettings = new Configuration(clientId, clientSecret1);
// Create an object of DocumentApi while passing configuration object as argument
var newApiInstance = new DocumentApi(configurationSettings);
try
{
var item1 = new JoinItem
{
FileInfo = new FileInfo
{
FilePath = "Binder1.pdf"
},
// pages of first PDF file to be combined
Pages = new List<int?> { 2, 3 }
};
var item2 = new JoinItem
{
FileInfo = new FileInfo
{
FilePath = "ten-pages.pdf"
},
StartPageNumber = 2,
EndPageNumber = 5,
RangeMode = JoinItem.RangeModeEnum.OddPages
};
var options = new JoinOptions
{
JoinItems = new List<JoinItem> { item1, item2 },
OutputPath = "myResultant.pdf"
};
// Create File JoinRequest
var requestOutput = new JoinRequest(options);
// merge PDF file files and upload the resultant PDF to cloud storage
var response = newApiInstance.Join(requestOutput);
}catch(Exception ex)
{ Console.WriteLine(ex.StackTrace); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment