Making te PAN tool selected by default

Product: WebViewer

Product Version: 10.8.0

I want to make the PAN tool selected by default.

When the document load event occurs, I want the PAN tool to be selected by default.

Currently I have set the FREETEXT to be selected when the document is loaded.
But going forward I have a change request to make the PAN tool to be selected when the document is first loaded

But it seems like an impossible task. Below are what I have already tried.

instance.UI.setToolMode(instance.Core.Tools.ToolNames.PAN);

and

documentViewer.addEventListener("documentLoaded", () => {
                documentViewer.setToolMode(
                    instance.Core.Tools.ToolNames.PAN
                );
});
1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


To set the PAN tool as the default tool when a document loads in WebViewer, you need to ensure that the tool is set after the document has fully loaded, using the correct tool mode identifier.

Some things you can try:

  • Ensure that you are using the correct tool name for the PAN tool, which is instance.Core.Tools.ToolNames.PAN.

  • Use the documentLoaded event to set the tool mode, ensuring that it is triggered after the document has fully loaded.

  • Verify that the event listener is correctly attached and the function is being called as expected.

  • Make sure there are no other conflicting tool mode settings being applied after your code runs.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

I have already tried multiple solutions you mentioned.

1 Like

Hi Subehera,

If you want to switch back to the PAN tool when loading a document, here is how you can achieve this:

documentViewer.addEventListener('documentLoaded', () => {
  documentViewer.setToolMode(documentViewer.getTool(Tools.ToolNames.PAN));
});

You were close but the API setToolMode is expecting a tool as parameters, to get the tool you can use the API getTool:

Let me know if you have any questions.

Best Regards,
Mickaƫl.

1 Like

Hi Mickaƫl,

Thank you very much for the solution.
I tried it and it kind of worked.

The problem is when I open the application (document loaded) the PAN tool is selected by default (which I wanted), but it gets unselected just after 1 second.

I have checked the code and nowhere the toolMode is changed programmatically.

1 Like

Hi Subehera,

Does this only happen when the Webviewer loads or for every loaded document?

Best Regards,
Mickaƫl.

1 Like

Hi Mickaƫl,

It happens when the Webviewer loads (reloading my react app), as well as when a document is loaded.

Thanks,
Subhra

1 Like

Hi Subehera,

I’m not able to reproduce the behavior you are describing.

Could you provide the file of your implementation containing your Webviewer constructor and uses of APIs.

If you cannot share this here, I invite you to create a ticket on the portal:

Best Regards,
Mickaƫl.

1 Like

Hi Mickaƫl,

Unfortunately, I cannot share the file here as it is against my organization’s policy.
However, I can simplify it by removing the business logic and share here.

Or do you want me to submit a ticket using the link you provided?

Thanks,
Subhra

1 Like

Hi Subehera,

I perfectly understand, but you might remove the logic that could induce your issue.

I invite you to create a ticket and provide your file.

Best Regards,
Mickaƫl.

1 Like

Hi Mickaƫl,

Understood, let me discuss with the team and then I will create a ticket.

Thanks,
Subhra

1 Like

Hi Mickaƫl,

Just to add, I tried with a bunch of other tools, like FREETEXT, CROP, TEXT_SELECT and SELECT.

documentViewer.addEventListener("documentLoaded", () => {
                documentViewer.setToolMode(
                    documentViewer.getTool(Tools.ToolNames.FREETEXT)
                );
            });

documentViewer.addEventListener("documentLoaded", () => {
                documentViewer.setToolMode(
                    documentViewer.getTool(Tools.ToolNames.TEXT_SELECT)
                );
            });

etc

All of them worked as expected, it is only the PAN tool which is malfunctioning.

Thanks,
Subhra

1 Like

Hi Subehera,

Using one of our samples, I’ve tried this code snippet, and it works just fine with the PAN tool.

I think something must be interfering with the rest of your code.

I invite you to try one of our samples and see if you can reproduce your issue.
You can find base samples here: Free Trial: JavaScript PDF Viewer | Apryse documentation

Best Regards,
Mickaƫl.

1 Like