Annotation sync

Annotations can be synced in realtime to allow for collaboration between clients.

Annotation sync for Xamarin.Android viewer

This tutorial only applies to Xamarin.Android.

Apryse supports annotation syncing between different clients to allow for collaboration. All the required locking, change tracking, merging and view updating are handled internally. Below are instructions on how to handle the import and export of annotation changes on the client side. While the server component is not described here, that implementation would be straightforward. The server would receive XFDF XML data, which it would then pass onto all other active clients that are part of the collaboration session. The clients take care of the updating. The server can store any XFDF data as it likes, since the data is just an XML string.

Requirements

Here are a few requirements for syncing to work as expected:

  • A permanent and unique string identifier is needed for the userId. UserId needs to be permanent and cannot be changed later on. For example, if Alice was used for the userId, however, was later changed to AliceB, the viewer will no longer treat it as the same user. Therefore, we recommend that you generate a UUID for each user.
  • Similar to userId, each annotation will also need its own UUID, aka annotId. This UUID also needs to be permanent and unique.
  • Annotation changes are stored as XFDF command strings, which PDFNet generates when changes are made. However, any custom modification to the XFDF command string could lead to unexpected results, thus, modification to the XFDF command string are not recommended.
  • Existing annotations that do not have a unique identifier will not work, it is recommended that you pre-process all annotations to make sure they all have unique identifiers.
  • Undo and redo will be automatically enabled upon using annotation syncing.

Initialize and sending annotation changes

Add the following after ToolManager is initialized:

C#

1// supply a permanent and unique userId here
2mToolManager.EnableAnnotManager("12345-67890-ABCD-EFGH");
3mToolManager.AnnotManager.LocalChanged += (sender, e) =>
4{
5 Console.WriteLine("LocalChanged: action: " + e.Action + ", xfdf: " + e.XfdfCommand);
6 // a local annotation change event has happened,
7 // now is the time to send the XFDF command string to your remote service
8 // action is one of {@link AnnotManager.AnnotationAction#ADD}
9 // {@link AnnotManager.AnnotationAction#MODIFY}
10 // {@link AnnotManager.AnnotationAction#DELETE}
11 // {@link AnnotManager.AnnotationAction#UNDO}
12 // {@link AnnotManager.AnnotationAction#REDO}
13 // xfdfCommand is the XFDF command string, modification to this string is not recommended
14};

Receive annotation changes

When an annotation change event is received from a remote service, add the following to notify the viewer about the change:

C#

1public void ReceivedAnnotationEvents(String xfdfCommand)
2{
3 mToolManager.AnnotManager?.OnRemoteChange(xfdfCommand);
4}

Jump to annotation

To jump to an annotation by id:

C#

1public void JumpToAnnotation(String annotId)
2{
3 mToolManager.AnnotManager?.JumpToAnnot(annotId);
4}

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales