PNG
JPG
BMP
TIFF
PDF
Merge PDF in .NET SDK
Merge two PDF files into one in C# Cloud API without the use of any software like Adobe PDF.
Get StartedHow to Merge Multiple PDF Files Using C# Cloud API
In order to merge two PDF files we’ll use Aspose.PDF Cloud .NET SDK This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open NuGet package manager, search for Aspose.PDF Cloud and install. You may also use the following command from the Package Manager Console.
Command
PM> Install-Package Aspose.Pdf-Cloud
Steps for Merging PDF via Cloud .NET SDK
A basic merging pdfs programmatically with Aspose.PDF Cloud .NET SDK APIs can be done with just few lines of code.
- Create a new Configuration object with your Application Secret and Key
- Create an object to connect to the Cloud API
- Upload your document file
- Perform the merging
- Download the result
Merge Two PDF Files using C#
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Merges
{
public class MergeDocuments
{
public static async Task Merge(MergesHelper helper, List<string> files, string outputName, string remoteFolder)
{
Aspose.Pdf.Cloud.Sdk.Model.MergeDocuments documetItems = new(new List<string>());
foreach (var file in files)
{
await helper.UploadFile(Path.GetFileName(file));
documetItems.List.Add(Path.Combine( remoteFolder, file));
}
DocumentResponse response = await helper.pdfApi.PutMergeDocumentsAsync(outputName, documetItems, folder: remoteFolder);
if (response == null)
Console.WriteLine("MergeDocuments(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("MergeDocuments(): Failed to documents.");
else
{
Console.WriteLine("MergeDocuments(): documents successfully merged to '{0}' file.", outputName);
await helper.DownloadFile(outputName);
}
}
}
}