This guide shows how to create a .NET console application that merges two PDF documents with the JoinPdf plugin.
Prerequisites
To build the example application, install the .NET SDK. The sample app targets .NET 10 (the current LTS release); the package itself supports .NET 6.0 or later. Visit the .NET download page to get the latest LTS version.
You can also skip the next steps and download the sample app that we’re going to build here.
Create a Console Application
Open your terminal and run the following commands to create a new console application:
dotnet new console -o merge-pdf-files
cd merge-pdf-files
Add the Package
Install the GroupDocs.Merger.LowCode package:
dotnet add package GroupDocs.Merger.LowCode
This adds a reference in your .csproj file with the latest available package version:
Replace the contents of Program.cs with the following code. It appends a one-page cost analysis to a business plan:
usingGroupDocs.Merger.Domain.Options;usingGroupDocs.Merger.LowCode;// Copy and paste your license keysvarpublicKey="<your public license key>";varprivateKey="<your private license key>";// Set the licenseLicense.Set(publicKey,privateKey);// Append the cost analysis to the business planvarmerger=newJoinPdf("business-plan.pdf",new[]{"cost-analysis.pdf"},newJoinOptions());// Save the merged documentmerger.Save("output/business-plan-with-costs.pdf");
Copy business-plan.pdf and cost-analysis.pdf to the project folder.
Run the Application
Run the application:
dotnet run
The merged document is saved to the output folder of the project. Without a license, the application runs in evaluation mode, and only the first three pages are processed. Request a temporary license to test the full functionality.