How to create HTML Annotation and exactly what is the use of it?

Please see https://groups.google.com/forum/#!searchin/pdfnet-webviewer/HTMLAnnotation|sort:date/pdfnet-webviewer/Cx2lkUtEvWo/Y0gukNDZDwAJ
How to create HTML Annotation and exactly what is the use of it?
Can you please provide a sample.

I have the same problem. Here is the code I wrote referring to demo, but how to set the HTML element?
I want to be able to create Annotation through HTML elements or HTML text.

function addHtmlAnnotation(elementId, point, rect) {
point = point || {};
rect = rect || {};
var Annotations = instance.Annotations;
var docViewer = instance.docViewer;
var annotManager = docViewer.getAnnotationManager();
var doc = docViewer.getDocument();
var displayMode = docViewer.getDisplayModeManager().getDisplayMode();
var page = displayMode.getSelectedPages(point, point);
if (!!point.x && page.first == null) {
return; // don’t add to an invalid page location
}
var pageIdx = page.first !== null ? page.first : docViewer.getCurrentPage() - 1;
var pageInfo = doc.getPageInfo(pageIdx);
var pagePoint = displayMode.windowToPage(point, pageIdx);
var zoom = docViewer.getZoom();

var annot = new Annotations.HTMLAnnotation();
annot.PageNumber = pageIdx + 1;
var rotation = docViewer.getCompleteRotation(pageIdx + 1) * 90;
annot.Rotation = rotation;
if (rotation === 270 || rotation === 90) {
annot.Width = rect.height / zoom;
annot.Height = rect.width / zoom;
} else {
annot.Width = rect.width / zoom;
annot.Height = rect.height / zoom;
}
annot.X = (pagePoint.x || pageInfo.width / 2) - annot.Width / 2;
annot.Y = (pagePoint.y || pageInfo.height / 2) - annot.Height / 2;

// annot.element = document.getElementById(elementId);
annot.Author = annotManager.getCurrentUser();

annotManager.deselectAllAnnotations();
annotManager.addAnnotation(annot);
annotManager.redrawAnnotation(annot);
annotManager.selectAnnotation(annot);
}

Hello Moka,

HTML Annotation is a base class for Widget type annotations like signature and text fields, etc. They are not meant to be instantiated or extended right now. If you are looking to programmatically add a type of annotation or create a custom one, I suggest taking a look at the guides below:

https://www.pdftron.com/documentation/web/guides/annotation/create-annotations/#programmatically

https://www.pdftron.com/documentation/web/guides/annotation/custom-annotations/

Let me know if this helps!

Andy Huang

Software Developer
PDFTron Systems Inc.