In pdf.js, how to enable manual control as the default setting?

I am using pdf.js to display pdf. I would like the hand tool to be enabled by default, and not to people who have access to it by pressing a button.

This is the html button code:

  <button id="toggleHandTool" class="secondaryToolbarButton handTool" title="Enable hand tool" tabindex="27" data-l10n-id="hand_tool_enable">
              <span data-l10n-id="hand_tool_enable_label">Enable hand tool</span>
            </button>

This is the code in the .js document:

    var HandTool = {
  initialize: function handToolInitialize(options) {
    var toggleHandTool = options.toggleHandTool;
    this.handTool = new GrabToPan({
      element: options.container,
      onActiveChanged: function(isActive) {
        if (!toggleHandTool) {
          return;
        }
        if (isActive) {
          toggleHandTool.title =
            mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
          toggleHandTool.firstElementChild.textContent =
            mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
        } else {
          toggleHandTool.title =
            mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
          toggleHandTool.firstElementChild.textContent =
            mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
        }
      }
    });
    if (toggleHandTool) {
      toggleHandTool.addEventListener('click', this.toggle.bind(this), false);
    }

toggle: function handToolToggle() {
this.handTool.toggle();
SecondaryToolbar.close();
 },

Can I add something to my html to include this right after the page loads? Or can I modify the .js file for this?

+3
source share
2 answers

I was just trying to achieve the same.

Apparently, it is as simple as changing enableHandToolOnLoad: falseup enableHandToolOnLoad: trueto viewer.js.

It was probably not possible at the time you posted this question.
+7
source

OK, I worked ...

I added:

<body onLoad="HandTool.toggle()">

to the end of html, just before

</body>
+3
source

All Articles