Get started with IronPDF

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer


Steps to Save & Edit PDF Revision History

  1. Download the C# Library to Save and Edit PDF Revision History with IronPDF
  2. Use the SaveAsRevision method to save the PDF as versions.
  3. Retrieve the PDF versions using the GetRevision method.
  4. Access the RevisionCount property to get the revision count.
  5. Save and export your PDF.

Save and Sign a PDF Revision Iteration

In the following example, we open a PDF file, make various edits, then before we save, we will sign it. For signature permissions, we will only allow form-filling as future edits; otherwise, the signature will be invalidated from any other edit.

We will then call SaveAsRevision to save the revision to the history and then save our new document to disk.

Please note
To improve PDF export performance, we have set the TrackChanges option to false. This option needs to be set to true to utilize the incremental save feature.

:path=/static-assets/pdf/content-code-examples/how-to/signing-revision.cs
using IronPdf;
using IronPdf.Rendering;

// Load the PDF file with change tracking enabled for detecting edits
PdfDocument pdf = PdfDocument.FromFile("annual_census.pdf", TrackChanges: ChangeTrackingModes.EnableChangeTracking);

// TODO: Perform various edits on the PDF document
// This is a placeholder for actual editing operations which might include:
// - Adding text or annotations
// - Modifying existing content
// Implement specific editing logic as per requirements here.

// Sign the PDF document using a digital signature
// The signature allows for additional signatures and form-filling permissions
pdf.SignWithFile("/assets/IronSignature.p12", "password", null, IronPdf.Signing.SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed);

// Save the document with changes as a new revision
PdfDocument pdfWithRevision = pdf.SaveAsRevision();

// Save the revised PDF document to a new file
pdfWithRevision.SaveAs("annual_census_2.pdf");
Imports IronPdf

Imports IronPdf.Rendering



' Load the PDF file with change tracking enabled for detecting edits

Private pdf As PdfDocument = PdfDocument.FromFile("annual_census.pdf", TrackChanges:= ChangeTrackingModes.EnableChangeTracking)



' TODO: Perform various edits on the PDF document

' This is a placeholder for actual editing operations which might include:

' - Adding text or annotations

' - Modifying existing content

' Implement specific editing logic as per requirements here.



' Sign the PDF document using a digital signature

' The signature allows for additional signatures and form-filling permissions

pdf.SignWithFile("/assets/IronSignature.p12", "password", Nothing, IronPdf.Signing.SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed)



' Save the document with changes as a new revision

Dim pdfWithRevision As PdfDocument = pdf.SaveAsRevision()



' Save the revised PDF document to a new file

pdfWithRevision.SaveAs("annual_census_2.pdf")
$vbLabelText   $csharpLabel

Understanding Incremental Saving for Signatures

While some viewers like the Chrome browser show only one version, PDF files have the capability to store previous versions of the document, similar to a Git commit history. You will see this in more advanced PDF viewers such as Adobe Acrobat.

When dealing with PDF signatures, it is important to know about this because the action of signing a PDF applies to the current iteration of the PDF. Your PDF may have signatures for older iterations or may have a few unsigned versions. We can visualize an example like this:

PDF Document Iteration Certificate A Certificate B Certificate C Certificate D
0 (first save)
1
2
3
(form field edits only)

(form field edits only)
4 (only form fields edited)
5
(no further edits allowed)

(no further edits allowed)

(no further edits allowed)

Above, we have a document that has been through 6 different iterations. This document may be passed around departments of a company with approval until being finalized at iteration 3. In this iteration, both Person A and Person B signed the document with the permission "Form Field Edits Only" set. This means that filling in form fields in the PDF document is allowed, but any other change to the document will invalidate their signatures.

In the example above, we can assume Person C is the one who has filled out the form and sent it back to Persons A, B, and D who all signed the document a final time with the "No Edits Allowed" permission. Since no invalidating actions were taken in this document, when we run IronPDF's signature method, we will get true.

Roll Back to an Old Revision

To roll back to a previous revision of a PDF, you can use the GetRevision method. This will forget any changes made since this revision, including newer signatures.

:path=/static-assets/pdf/content-code-examples/how-to/signing-revert-revision.cs
/// <summary>
/// This code snippet uses the IronPdf library to load a PDF document,
/// retrieve a specific revision of the PDF, and save that revision as a new file.
/// </summary>

using IronPdf; // Importing the IronPdf namespace for PDF manipulation

// Load an existing PDF document from a file named "report.pdf".
PdfDocument pdf = PdfDocument.FromFile("report.pdf");

// Retrieve the total number of revisions available in the PDF document.
int versions = pdf.RevisionCount;

// Ensure that the desired revision is within the valid range.
if (versions > 1)
{
    // Retrieve the second revision of the PDF document.
    // Note: Revision numbers are zero-indexed; however, this code assumes a 1-based index for illustrative purposes.
    PdfDocument rolledBackPdf = pdf.GetRevision(1);

    // Save the retrieved revision as a new PDF file named "report-draft.pdf".
    rolledBackPdf.SaveAs("report-draft.pdf");
}
else
{
    // Handle the case where insufficient revisions are available.
    Console.WriteLine("The PDF does not have enough revisions to retrieve the requested version.");
}

/// <note>
/// It's important to ensure that the correct revision index is used. 
/// Typically, index values start at 0. However, this example uses an index of 1 to access the second revision,
/// assuming the desired revision based on the library's documentation or previous assumption.
/// </note>
''' <summary>

''' This code snippet uses the IronPdf library to load a PDF document,

''' retrieve a specific revision of the PDF, and save that revision as a new file.

''' </summary>



Imports IronPdf ' Importing the IronPdf namespace for PDF manipulation



' Load an existing PDF document from a file named "report.pdf".

Private pdf As PdfDocument = PdfDocument.FromFile("report.pdf")



' Retrieve the total number of revisions available in the PDF document.

Private versions As Integer = pdf.RevisionCount



' Ensure that the desired revision is within the valid range.

If versions > 1 Then

	' Retrieve the second revision of the PDF document.

	' Note: Revision numbers are zero-indexed; however, this code assumes a 1-based index for illustrative purposes.

	Dim rolledBackPdf As PdfDocument = pdf.GetRevision(1)



	' Save the retrieved revision as a new PDF file named "report-draft.pdf".

	rolledBackPdf.SaveAs("report-draft.pdf")

Else

	' Handle the case where insufficient revisions are available.

	Console.WriteLine("The PDF does not have enough revisions to retrieve the requested version.")

End If



''' <note>

''' It's important to ensure that the correct revision index is used. 

''' Typically, index values start at 0. However, this example uses an index of 1 to access the second revision,

''' assuming the desired revision based on the library's documentation or previous assumption.

''' </note>
$vbLabelText   $csharpLabel

Frequently Asked Questions

What is PDF revision history?

PDF revision history is a feature that allows you to track and manage changes made to a PDF document over time, commonly used in collaborative environments to maintain a record of revisions.

How can I save a PDF as a revision?

You can use the `SaveAsRevision` method in IronPDF to save the current state of a PDF document as a new version, thus creating a revision history.

How do I retrieve a specific revision of a PDF document?

You can use the `GetRevision` method in IronPDF to retrieve a specific revision of a PDF document, allowing you to access or roll back to that version.

What is incremental saving in the context of PDF signatures?

Incremental saving allows a PDF to store changes incrementally, similar to a commit history, which is important for managing digital signatures that apply to specific document iterations.

How do digital signatures affect PDF revision history?

Digital signatures in PDFs apply to specific iterations; any changes invalidating the signature will affect that iteration's validity. IronPDF can manage these iterations and signatures effectively.

Can permissions be managed for PDF signatures?

Yes, IronPDF allows you to set permissions such as 'AllowFormFilling' for signatures, which restricts edits to form fields only, ensuring signature integrity.

What happens when I roll back to a previous revision?

Rolling back to a previous revision using IronPDF's `GetRevision` method reverts the document to that state, forgetting any changes and signatures made after that revision.

How is PDF export performance improved?

IronPDF can improve PDF export performance by setting the TrackChanges option to false, although enabling it is necessary for incremental saving and revision history.

Where can the library be downloaded?

You can download the IronPDF library from the NuGet package repository at https://nuget.org/packages/IronPdf/.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.