Unable to see text fields in the comment box

Product: Apryse PDFTron

Product Version: 10.8.0

Hello, I used the following code to create a text field with the help of text widget annotation.

WebViewer(...)
.then(instance => {
  const { annotationManager, Annotations } = instance.Core;
  const { WidgetFlags } = Annotations;

  // myBtn is your own custom button
  document.getElementById('myBtn').addEventListener('click', () => {

    // set flags for multiline and required
    const flags = new WidgetFlags();
    flags.set('Multiline', true);
    flags.set('Required', true);

    // create a form field
    const field = new Annotations.Forms.Field("some text field name", {
      type: 'Tx',
      defaultValue: "some placeholder default text value",
      flags,
    });

    // create a widget annotation
    const widgetAnnot = new Annotations.TextWidgetAnnotation(field);

    // set position and size
    widgetAnnot.PageNumber = 1;
    widgetAnnot.X = 100;
    widgetAnnot.Y = 100;
    widgetAnnot.Width = 50;
    widgetAnnot.Height = 20;

    //add the form field and widget annotation
    annotationManager.getFieldManager().addField(field);
    annotationManager.addAnnotation(widgetAnnot);
    annotationManager.drawAnnotationsFromList([widgetAnnot]);
  });
});

But the text field created is not shown in the comments box present in the right side.
Also it disappears when I go to the Forms header tab from the View header tab.
image

Disappears in the forms tab

1 Like

Hello subhra,

It is expected that you would not see if in the comments panel when not editing the fields.
If you are editing the field in Form Field Edit mode you will see the placeholders in the comment box, until applied.

Best regards,
Tyler

1 Like

Hey Tyler,
Thank you for replying.

I see the FreeTextAnnotations in the comments box at every moment, wheather I am editing them or not.
I want the same behaviour for the TextFields as well.

Is there any way to achieve that?

Thanks,
Subhra

Hello Subhra,

Widgets are not viewable in the annotations list by design. However, you can set the Listable property to True to actually see them. Keep in mind that as this is not intended, some UI properties may not be present.

Please add the following to your code:

widgetAnnot.Listable = true;

Best Regards,
Luke

Thank you, Luke

I will try the solution.