Create a custom button to toggle an annotaion element i.e free text

Product:

Product Version:

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

In the uploaded image on the custom left side panel, there is a list mention of placeholders. I want to toggle the free text annotation element by clicking on the copy button as well as I want to copy the placeholder string at the same time.

2nd query: when we click on free text element and use it on pdf page a default line comes “Insert text here” how can i change that with my placeholder string which i copied by clicking on the button.

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

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

Hello Rikochet007,

Thank you for contacting Webviewer Support.

We will investigate your inquiry and let you know when we have further information.

Best Regards,

Carlo Mendoza
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

Hello Rikochet007,

To follow-up on your inquiry, you can make your custom button set the tool mode to Free Text like so:

document.getElementById("yourButton").onclick = (e) => {
    instance.setToolMode("AnnotationCreateFreeText");
};

To set the contents of the Free Text, you can use the setContents() function on the Free Text Annotation.

You would probably also need to add an event handler in this case to capture when a new Free Text Annotation is created and set the contents there. We have a guide on Annotation Events here: PDFTron Systems Inc. | Documentation.

Hope this helps!

Best Regards,

Carlo Mendoza
Software Developer
PDFTron Systems, Inc.
www.pdftron.com