The ability to compare PDF files is indispensable for legal professionals, contract managers, and anyone needing to verify document integrity. By highlighting changes, deletions, and additions, our .NET Cloud SDK removes the guesswork and manual effort from document review, and significantly reduces the risk of errors. Let’s explore the details on how we can utilize the powerful capabilities of Cloud SDK and automate the PDF comparison process.
REST API to Compare PDF Files
GroupDocs.Comparison Cloud SDK for .NET offers a robust and versatile solution for comparing PDF files, designed to meet the needs of professionals who require precise and efficient document comparison. The SDK provides a comprehensive set of features that allow you to automate and streamline the comparison process, ensuring accuracy and consistency across your documents.
The first step is to install the SDK by searching GroupDocs.comparison-cloud in NuGet package manager and then, click the Install button. Alternatively, you may consider executing the following command in package manager console.
NuGet\Install-Package GroupDocs.Comparison-Cloud -Version 24.4.0
Once the Cloud SDK is installed, then we need to obtain a personalized API credentials(i.e. Client ID and Client Secret). Please follow the instructions specified in this short tutorial explaining the details on how to get the API credentials.
Compare PDF Documents in C#
In this section, we are going to utilize the powerful capabilities of .NET Cloud SDK, and automate the PDF comparison process, ensuring meticulous identification of differences between document versions.
- Create an instance of
Configuration
class where we pass client credentials as arguments.
var configuration = new Configuration(clientId, clientSecret);
- Initialize the
ConvertApi
where we pass Configuration object as an input argument.
var comparisonApiInstance = new CompareApi(configuration);
- Here we define the comparison option defining input PDF file and target PDF to compare with.
var options2 = new ComparisonOptions
- Create a list instance and specify the names of files to be compared.
TargetFiles = new List<GroupDocs.Comparison.Cloud.Sdk.Model.FileInfo> {....}
- Finally, call the API to perform PDF comparison and save the resultant PDF file in Cloud storage.
var changes = comparisonApiInstance.PostChanges(request);
The input PDF used in the above example can be downloaded from binder.pdf.
Compare Two PDFs using cURL Commands
GroupDocs.Comparison Cloud offers a seamless and efficient method to compare PDF files using simple cURL commands. This approach is particularly handy for developers and IT professionals looking for a quick, platform-independent solution to integrate document comparison capabilities into their workflows without extensive coding or setup.
The first step in this approach is to generate the JWT access token based on client credentials. Once we have the JWT token, we need to execute the following cURL command to compare two PDF files and generate a resultant PDF document highlighting the differences.
curl -v -X POST "https://api.groupdocs.cloud/v2.0/comparison/comparisons" \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"SourceFile\": { \"FilePath\": \"{FirstPDF}\" }, \"TargetFiles\": [ { \"FilePath\": \"{secondPDF}\" } ], \"Settings\": { \"GenerateSummaryPage\": true, \"ShowDeletedContent\": true, \"ShowInsertedContent\": true, \"StyleChangeDetection\": true, \"UseFramesForDelInsElements\": true, \"CalculateComponentCoordinates\": true, \"MarkChangedContent\": true, \"MarkNestedContent\": true, \"MetaData\": { \"Author\": \"Nayyer Shahbaz\", \"LastSaveBy\": \"Nayyer Shahbaz\", \"Company\": \"GroupDocs.Cloud\" }, \"HeaderFootersComparison\": true, \"SensitivityOfComparison\": 0 }, \"OutputPath\": \"{resultantPDF}\"}"
Please replace FirstPDF
with the name of source PDF file and secondPDF
with the name of target PDF document to be compared with. Also, replace resultantPDF
with the name of resultant PDF file to be generated and accessToken
with a personalized JWT access token.
Compare PDF Documents Online for Free
You may consider trying our free, lightweight and supper-efficient PDF Comparison App, developed using GroupDocs.Conversion Cloud APIs. You can experience the amazing capabilities of Cloud SDK to compare PDF files without any installation.
Useful Links
Conclusion
In this article, we have explored the details on how to leverage GroupDocs.Comparison Cloud SDK to streamline the PDF comparison process using both C# .NET and cURL commands. Therefore, by utilizing these powerful tools, you can automate the detection of changes, deletions, and additions in your PDF files, reducing manual effort and enhancing productivity. Please discover the benefits of these approaches and learn how to implement them effectively for accurate and reliable document management.
Related Articles
We also recommend visiting the following links to learn more about: