Collaboration: New Annotations Sample
We just published a new sample to our live demos that shows how to use the annotation feature of the online DocumentViewer. It shows how to load and save the annotations as separate JSON files.

The latest release version of the TX Text Control DocumentViewer for ASP.NET, ASP.NET Core and Angular comes with document collaboration features such as annotations and comments. It allows you to add and share annotations from different users to any type of document supported by TX Text Control including PDF, DOC, DOCX, RTF and the internal TX Text Control format (TX).
This allows an easy integration of document collaboration workflow features into your TX Text Control based applications.
The DocumentViewer can be initialized with a user name that defines the current user using the UserNames property:
<div class="tx-container">
@Html.TXTextControl().DocumentViewer(settings => {
settings.DocumentPath = Server.MapPath("~/App_Data/Documents/invoice_results.docx");
settings.Dock = DocumentViewerSettings.DockStyle.Fill;
settings.IsSelectionActivated = true;
settings.ShowThumbnailPane = false;
settings.UserNames = new string[] { "Tim Typer" };
}).Render()
</div>
When the demo is initialized, the annotation toolbar is opened automatically to show the annotations in the sidebar:

The annotations are not stored within the document which allows you to share annotations with all document types that are supported including DOCX, DOC, RTF and PDF. On loading the viewer, the annotation JSON is loaded using the JavaScript method annotation.load:
window.addEventListener("documentViewerLoaded", function () {
var annotationJSON =
"[[{ \"pen\":{\"width\":18,\"color\":\"rgba(255, 255, 0, .5)\",\"cap\":\"butt\" [...]";
TXDocumentViewer.annotations.load(annotationJSON);
});
You can add additional annotations and comments to the document:

The two green buttons at the bottom of the demo show how to save and load the annotations:

On clicking Export Annotations JSON, the complete annotations are serialized as JSON and copied into a text area. Using the button Load Annotations JSON, you can load the exported annotations back into the viewer.
function exportAnnotations() {
$("#taAnnotations").val(TXDocumentViewer.annotations.export());
}
function loadAnnotations() {
var annotationData = $("#taAnnotations").val();
try {
TXDocumentViewer.annotations.load(annotationData);
} catch (error) {
$('.alert').show().delay(3000).fadeOut(300);
}
}
You can try this on your own by launching the live demo:
Angular
Integrate document processing, editing, sharing, collaboration, creation, electronic signatures, and PDF generation into your Angular Web applications.
Related Posts
Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor…
This article shows how to create a backend for the Document Editor and Viewer using ASP.NET Core. The backend can be hosted on Windows and Linux and can be used in Blazor, Angular, JavaScript, and…
ASP.NETASP.NET CoreCollaboration
Adding and Sharing Annotations across Document Types using the Document…
Learn how to add and share annotations across different document types using the Document Viewer in ASP.NET Core C#. This article shows how to create a simple web application that allows users to…
Building an ASP.NET Core Backend Application to Host the Document Editor and…
This article explains how to create an ASP.NET Core backend application to host the Document Editor and Document Viewer. This backend application is required to provide the required functionality…
Customizing Electronic Signature Fonts for Typed Signatures in Angular and…
This article shows how to customize the electronic signature fonts for typed signatures in Angular and ASP.NET Core. It explains how to use custom fonts for the signature appearance and how to…
Preview: PDF.js Support for Form Fields, Selections and Annotations
We are working on new features for the Document Viewer and it's PDF.js support including filling out form fields, selecting and finding text and annotations. This article gives an overview of some…
