Versioning of annotated documents

When you save a file using the Annotator.Save() method, the GroupDocs.Annotations creates a version of the annotated file. Versions list keeps annotations that you add, remove, and change. You can swap between different changes made with GroupDocs.Annotation. If needed, you can set custom version names.

By default, GroupDocs.Annotations names version using a GUID. If needed, you can specify a custom version name.

Add version with custom name

You can specify a custom version name.

The following code snippet shows how to save version with custom name:

using (Annotator annotator = new Annotator("input.pdf"))
{
	annotator.Update(new AreaAnnotation{ Box = new Rectangle(100, 100, 100, 100) });
	annotator.Save("result.pdf", new SaveOptions { Version = "CUSTOM_VERSION" });
}
Note
The Version property is object.

Get the list of version keys of a file

To get the list of version keys, call the GetVersionsList method of the Annotator class.

The following code snippet shows how to get list of versions keys:

using (Annotator annotator = new Annotator("result.pdf")) { 
      List<object> versionKeys = annotator.GetVersionsList();
}
Note
The Annotator.GetVersionList() method returns list of objects. If needed, you can convert them to appropriate type.

Get the list of annotations using version key

To get the list of annotations in a specific version, call the Annotator.GetVersion() method of the Annotator class.

The following code snippets shows how to get list of annotations in a specific version:

using (Annotator annotator = new Annotator("result.pdf"))
{
    List<AnnotationBase> annotations = annotator.GetVersion("CUSTOM_VERSION");
}
Note
The GetVersion method returns list of objects. If needed, you can convert them to appropriate type.

Load a specific file version

To load a specific version of a file, specify the LoadOptions.Version property.

The following code snippets shows how load version using version property:

 using (Annotator annotator = new Annotator($"result.{ext}", new LoadOptions { Version = "CUSTOM_VERSION" }))
{
	annotator.Save("result_loaded.pdf");
}