Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
In this tutorial, we explore how to save and edit PDF revision history using Iron PDF in a C# console application. We begin by ensuring Iron PDF is installed via the NuGet package manager and setting up the IronPDF license. The tutorial guides you through importing a PDF file and enabling change tracking, allowing any modifications to be recorded. We demonstrate signing the PDF with a digital signature from a PFX file to maintain document integrity and authenticity. Next, we save changes as a new revision, enabling version tracking. The revision count property is checked to display the total number of saved revisions. We also illustrate how to roll back to a previous revision, ensuring flexibility in document management. The tutorial concludes with a successful execution of the project, showcasing the revised PDF files with digital signatures. For those interested in experiencing Iron PDF's capabilities, a trial is available for download. This tutorial serves as a practical guide for efficiently managing PDF revisions, ensuring secure and authentic documentation.
using System;
using IronPdf;
class Program
{
static void Main()
{
// Set your IronPDF license key here
// IronPdf.License.LicenseKey = "your_license_key";
// Load an existing PDF document
var pdfDocument = PdfDocument.FromFile("YourPDFDocument.pdf");
// Enable change tracking for the PDF document
pdfDocument.EnableChangeTracking();
// Import a digital signature from a PFX file
// Replace "YourPfxFile.pfx" and "your_password" with the correct values
var signature = new PdfSignature("YourPfxFile.pfx", "your_password");
// Sign the PDF to ensure its integrity and authenticity
pdfDocument.Signature = signature;
// Make a modification and save as a new revision
// Add a new page for demonstration
var newPage = pdfDocument.AddPage();
newPage.HtmlContent = "<h1>New Revision Content</h1>";
pdfDocument.SaveAs("RevisedPDFDocument.pdf");
// Display the current revision count
var revisionCount = pdfDocument.RevisionCount;
Console.WriteLine($"Total number of saved revisions: {revisionCount}");
// Roll back to the previous revision if needed
pdfDocument.RollbackTo(revisionCount - 1);
pdfDocument.SaveAs("RolledBackPDFDocument.pdf");
Console.WriteLine("PDF revision operation is successful.");
}
}
using System;
using IronPdf;
class Program
{
static void Main()
{
// Set your IronPDF license key here
// IronPdf.License.LicenseKey = "your_license_key";
// Load an existing PDF document
var pdfDocument = PdfDocument.FromFile("YourPDFDocument.pdf");
// Enable change tracking for the PDF document
pdfDocument.EnableChangeTracking();
// Import a digital signature from a PFX file
// Replace "YourPfxFile.pfx" and "your_password" with the correct values
var signature = new PdfSignature("YourPfxFile.pfx", "your_password");
// Sign the PDF to ensure its integrity and authenticity
pdfDocument.Signature = signature;
// Make a modification and save as a new revision
// Add a new page for demonstration
var newPage = pdfDocument.AddPage();
newPage.HtmlContent = "<h1>New Revision Content</h1>";
pdfDocument.SaveAs("RevisedPDFDocument.pdf");
// Display the current revision count
var revisionCount = pdfDocument.RevisionCount;
Console.WriteLine($"Total number of saved revisions: {revisionCount}");
// Roll back to the previous revision if needed
pdfDocument.RollbackTo(revisionCount - 1);
pdfDocument.SaveAs("RolledBackPDFDocument.pdf");
Console.WriteLine("PDF revision operation is successful.");
}
}
Imports System
Imports IronPdf
Friend Class Program
Shared Sub Main()
' Set your IronPDF license key here
' IronPdf.License.LicenseKey = "your_license_key";
' Load an existing PDF document
Dim pdfDocument = PdfDocument.FromFile("YourPDFDocument.pdf")
' Enable change tracking for the PDF document
pdfDocument.EnableChangeTracking()
' Import a digital signature from a PFX file
' Replace "YourPfxFile.pfx" and "your_password" with the correct values
Dim signature = New PdfSignature("YourPfxFile.pfx", "your_password")
' Sign the PDF to ensure its integrity and authenticity
pdfDocument.Signature = signature
' Make a modification and save as a new revision
' Add a new page for demonstration
Dim newPage = pdfDocument.AddPage()
newPage.HtmlContent = "<h1>New Revision Content</h1>"
pdfDocument.SaveAs("RevisedPDFDocument.pdf")
' Display the current revision count
Dim revisionCount = pdfDocument.RevisionCount
Console.WriteLine($"Total number of saved revisions: {revisionCount}")
' Roll back to the previous revision if needed
pdfDocument.RollbackTo(revisionCount - 1)
pdfDocument.SaveAs("RolledBackPDFDocument.pdf")
Console.WriteLine("PDF revision operation is successful.")
End Sub
End Class
Further Reading: How to Save & Edit PDF Revision History