About FreeHand Annotation

WebViewer Version:
@pdftron/webviewer”: “^10.1.0”,

Do you have an issue with a specific file(s)?
No.
Can you reproduce using one of our samples or online demos?
No.
Are you using the WebViewer server?
No.
Does the issue only happen on certain browsers?
No.
Is your issue related to a front-end framework?
No.
Is your issue related to annotations?
Yes, FreeHand.

Please give a brief summary of your issue:
(Think of this as an email subject)

About FreeHand Annotation.

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

  1. case annotationChanged Event.
    sample code.
WebViewer(...)
  .then(instance => {
    const { annotationManager } = instance.Core;

    annotationManager.addEventListener('annotationChanged', (annotations, action) => {
        console.log('-------------------onAnnotationChanged action=' + action);
   });

1-1. Create freehand annotations.

1-2.
LOG : console.log(‘-------------------onAnnotationChanged action=’ + action);
It may take a few seconds for the console.log to appear.


AnnotationChangeEvent is slow.
FreeHand only.

  1. case API : getAnnotationsList().
    sampleCode.
  public buttonClick = () => {
        const getAnnots =
      this.viewerInstance.Core.annotationManager.getAnnotationsList();

    if (getAnnots.length > 0) {
     ......
  }
  

2-1. Click the button immediately after creating the annotation.
Cannot be get with getAnnotationsList API.
(length === 0)
image

These incidents are freehand annotations only.

[Background for this topic]
Fired when the user clicks the DB save button right after creating a freehand annotation.
Are there any countermeasures?

Please provide a link to a minimal sample where the issue is reproducible:

Best Regards.

Hello,

There is an expected delay in free hand annotation creation in order to capture multiple strokes as part of the same annotation. You can read more about that here and how to adjust that delay: Apryse Documentation | Documentation.

Let me know if that helps!

Hello,

Thank you for the advice.
I tried this.
But it didn’t improve.

WebViewer(...)
  .then(function(instance) {
   instance.Core.Tools.FreeHandCreateTool.prototype.createDelay = 0;
  });

It looks like that code is a bit outdated and there is an API for that now: setCreateDelay. I think you may have to set it on each of the tools themselves:

const toolMap = instance.Core.documentViewer.getToolModeMap();
Object.keys(toolMap).forEach(toolKey => {
    if (toolKey.startsWith('AnnotationCreateFreeHand')) {
        toolMap[toolKey].setCreateDelay(0);
    }
})
1 Like

This code worked very well for me.

Thank you!!