How to enable this option by default in pdfjs-express-viewer

hello everygone I use in react js pdf viewer free and need to for default active to option that points in the image that I uploaded

/version/
^8.2.1

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi There,

Here is a ticket with a similar question.

Hope this helps and let me know if this works for you.

Thank you,

Dandara

1 Like

hello i use to code to sample and it does not work

 useEffect(() => {
    WebViewer(
      {
        licenseKey: "nkrJM83iXlKQYjD8wPcX",
        path: "/webviewer/lib",
        initialDoc:
          "https://firebasestorage.googleapis.com/v0/b/pruebas-juridicapp-abogados.appspot.com/o/Abogados%2FwPMnKZMLVYRp1fUSJDfEKMTVMVn1%2Fcasos%2F6zYAk2A5enNRnjV8abWW%2FDocumentos%2Fdocumento1_.pdf?alt=media&token=325b1cc0-9d3b-474e-b6ad-e0325dfc7228",
      },
      viewer.current
    ).then((instance) => {
      // now you can access APIs through the WebViewer instance
      const { Core } = instance;
      /*change lenguage */
      instance.UI.setLanguage("es");

      const panTool = Core.Tools.ToolNames.PAN;
      instance.UI.setToolMode(panTool);

      // remove left panel and left panel button from the DOM
      instance.UI.disableElements([
        "textSelectButton",
        "selectToolButton",
        "searchButton",
        "printButton",
      ]);

      /*disable Functions */
      instance.disableFeatures([instance.Feature.Print]);
      instance.disableFeatures([instance.Feature.TextSelection]);
      instance.disableFeatures([instance.Feature.Copy]);
      instance.disableFeatures([instance.Feature.FilePicker]);

      // adding an event listener for when a document is loaded
      Core.documentViewer.addEventListener("documentLoaded", () => {
        console.log("document loaded", instance.Feature);
      });

      // adding an event listener for when the page number has changed
      Core.documentViewer.addEventListener(
        "pageNumberUpdated",
        (pageNumber) => {
          console.log(`Page number is: ${pageNumber}`);
        }
      );
    });
  }, []);

Hi There,

Please try to use the following code.

useEffect(() => {
    WebViewer(
      {
        licenseKey: "nkrJM83iXlKQYjD8wPcX",
        path: "/webviewer/lib",
        initialDoc:
          "https://firebasestorage.googleapis.com/v0/b/pruebas-juridicapp-abogados.appspot.com/o/Abogados%2FwPMnKZMLVYRp1fUSJDfEKMTVMVn1%2Fcasos%2F6zYAk2A5enNRnjV8abWW%2FDocumentos%2Fdocumento1_.pdf?alt=media&token=325b1cc0-9d3b-474e-b6ad-e0325dfc7228",
      },
      viewer.current
    ).then((instance) => {
      // now you can access APIs through the WebViewer instance
      const { Core } = instance;

    /* disable Functions */
    instance.disableFeatures([instance.Feature.Print]);
    instance.disableFeatures([instance.Feature.TextSelection]);
    instance.disableFeatures([instance.Feature.Copy]);
    instance.disableFeatures([instance.Feature.FilePicker]);

    /*change language */
    instance.UI.setLanguage("es");

    const panTool = Core.Tools.ToolNames.PAN;
    instance.UI.setToolMode(panTool);

    // remove left panel and left panel button from the DOM
    instance.UI.disableElements([
      "textSelectButton",
      "selectToolButton",
      "searchButton",
      "printButton",
    ]);

    // adding an event listener for when a document is loaded
    Core.documentViewer.addEventListener("documentLoaded", () => {
      console.log("document loaded", instance.Feature);
    });

    // adding an event listener for when the page number has changed
    Core.documentViewer.addEventListener(
      "pageNumberUpdated",
      (pageNumber) => {
        console.log(`Page number is: ${pageNumber}`);
      }
    );
  });
  }, 
[]);

I changed the code execution order a bit and it worked on my side.

Let me know if this works for you.

Thank you,
Dandara

1 Like