7 Replies Latest reply on May 25, 2016 8:34 AM by ZoPaars

    app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)

    ZoPaars Level 1

      Maybe I am doing something wrong, but here is my code that is put in a document-level JavaScript:

       

      function MakeButtons() {
              app.addToolButton({
                  cName : "ResetButton",
                  cExec : "ResetAll()",
                  cTooltext : "Reset the entire sheet and all form fields to their initial value.",
                  nPos : 1,
                  cLabel : "Reset"
              });
      
              app.addToolButton({
                  cName : "ImportExportButton",
                  cExec : "ImportExport_Button()",
                  cTooltext : "Import or Export form data with the .fdf or .xfdfd file extension.\n\nYou can select to only export the data that is not auto-filled by the sheet.\n\nThis menu also offers the option to add your own code to the sheet. For more information on this, see the FAQ.",
                  nPos : 2,
                  cLabel : "Im\/Export"
              });
      }
      MakeButtons();
      

       

      I have several document with this exact code. When I open one of these documents, I get a "JavaScript-Window" with both these buttons. However, when I open a second document, I get no such window. Even when I close all the documents, but leave Acrobat running, and open a document again, I don't get this "JavaScript-Window".

       

      Running the "MakeButtons()" function from console also has no effect.

       

      This behaviour is new for Acrobat DC, because in Acrobat XI every opened document would have their buttons shown without a problem. Even in earlier versions of Acrobat DC (I am now running 15.01620041 on Windows) this was not an issue (although I don't know what version it was still working).

       

      Does anybody know of a way to change the code to make this working again? Or is it something I should take up with the Adobe support staff?

        • 1. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
          Karl Heinz Kremer Adobe Community Professional

          If it worked in previous releases of Acrobat, and also worked in earlier versions of Acrobat DC, I would suspect that this is a bug that was introduced recently. You can report a bug here: Feature Request/Bug Report Form

           

          Once you select "Adobe Acrobat Pro", the form will redirect you to a page that is not hosted on Adobe's web server, that is OK.

          • 2. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
            meenakshin83966505 Adobe Employee

            Hi ZoPaars,

             

            Along with as mentioned by Karl, once refer this thread with similar issue : app.addToolButton code

            Also enable the JavaScript debugger as it displays the following error:

            ReferenceError: ResetAll is not defined

            1:Doc:Exec

            ReferenceError: ImportExport_Button is not defined

            1:Doc:Exec

            Check if this helps.

             

            Regards,

            Meenakshi

            • 3. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
              Karl Heinz Kremer Adobe Community Professional

              The code posted was not complete: The OP left out the function that are being called when one of the button is clicked on. What this code is does not matter because it does not add anything useful to the problem report. You can use for example this as a document level script:

               

              function ResetAll() {
                  app.alert("ResetAll()");
              }
              
              function ImportExport_Button() {
                  app.alert("ImportExport_Button()");
              }
              
              function MakeButtons() { 
                      app.addToolButton({ 
                          cName : "ResetButton", 
                          cExec : "ResetAll()", 
                          cTooltext : "Reset the entire sheet and all form fields to their initial value.", 
                          nPos : 1, 
                          cLabel : "Reset" 
                      }); 
              
                      app.addToolButton({ 
                          cName : "ImportExportButton", 
                          cExec : "ImportExport_Button()", 
                          cTooltext : "Import or Export form data with the .fdf or .xfdfd file extension.\n\nYou can select to only export the data that is not auto-filled by the sheet.\n\nThis menu also offers the option to add your own code to the sheet. For more information on this, see the FAQ.", 
                          nPos : 2, 
                          cLabel : "Im\/Export" 
                      }); 
              } 
              MakeButtons();
              

              You will see the same behavior as described: As soon as a second document gets opened, the floating toolbar goes away. This is different behavior compared to e.g. Acrobat XI where the floating window attaches itself to the document.

               

              The functionality of these tools is still available however - just not via the floating toolbar: You can still access the tools via the "Tools" right hand pane:

               

              2016-05-24_15-16-14.png

               

              What's interesting here is that one document will have only two tools listed, whereas the other one will have four:

               

              2016-05-24_15-17-32.png

               

              In Acrobat XI Pro, both documents (open at the same time) will show four tools, to of them active, and two of them inactive.

               

              Again, the behavior is different than in previous versions of Acrobat, so I would consider this a bug.

              1 person found this helpful
              • 4. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
                gkaiseril MVP & Adobe Community Professional

                Are you sure you have the necessary functions existing within the documents or as a folder level functions?

                 

                I see no code to check for the existence of the reset or import/export functions. Hint use the typeof constrictor.

                 

                I have tried the following code as a document level function in multiple documents and the expected floating tool bar appears.

                 

                function ResetAll()
                {
                app.alert("ResetAll function", 1, 0);
                }

                function ImportExport_Button()
                {
                app.alert("Import Export Function", 1, 0);
                }


                function MakeButtons()
                {
                // check to see if ResetAll function exist;
                if(typeof ResetAll == "function") {
                // try to remove "RestButton" so there is not duplicate button;
                try {
                  app.removeToolButton("ResetButton");
                  } catch(e) {}

                        app.addToolButton({
                            cName : "ResetButton",
                            cExec : "ResetAll()",
                            cTooltext : "Reset the entire sheet and all form fields to their initial value.",
                            nPos : 1,
                            cLabel : "Reset"
                        });
                }
                else
                {
                  app.alert("Missing \"ResetAll\" function!", 0, 0);
                  }
                 
                // check to see if "ImportExportButton" function exist
                   if(typeof ImportExport_Button == "function")
                   {
                    // try to remove button so there is no duplicate;
                  try {
                   app.removeToolButton("ImportExportButton");
                   } catch(e) {}

                        app.addToolButton ({
                          cName : "ImportExportButton",
                            cExec : "ImportExport_Button()",
                            cTooltext : "Import or Export form data with the .fdf or .xfdfd file extension.\n\nYou can select to only export the data that is not auto-filled by the sheet.\n\nThis menu also offers the option to add your own code to the sheet. For more information on this, see the FAQ.",
                            nPos : 2,
                            cLabel : "Im\/Export"
                        });
                        }
                        else
                        {
                   app.alert("Missing \"ImportExportButton\" function.", 0, 0);
                   }
                } // end MakeButtons function;

                MakeButtons();

                 

                Note that using the above code as a document level function will add a floating toolbar.

                 

                Using the code as a folder level function will add the code as Add-on Tools. You can hide the floating with by adding the hideToolBarButton method.

                • 5. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
                  try67 MVP & Adobe Community Professional

                  I've also noticed a bug with addToolButton in the latest version of Acrobat Pro DC (2015.016.20041). When used in a folder-level script it adds both a toolbar item above the document (which is confusing and annoying, as it used to appear in the right-hand panel), as well as a button in a floating "Add-on Tools" toolbar.

                   

                   

                  In addition, the Add-on Tools link on the right often disappears from the panel without rhyme or reason. Very annoying...

                  • 6. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
                    gkaiseril MVP & Adobe Community Professional

                    You need to add the hideToolbarButton for one button to hide the tool bar created by the folder level script.

                     

                    I get the floating tool bar

                     

                    FloFloating2.jpg

                    • 7. Re: app.addToolButton() no longer works in second open document (Acrobat DC 15.01620041)
                      ZoPaars Level 1

                      Thanks everybody for your replies and thank you for having the most in-depth answers here. I did indeed not post a complete code, as I didn't think the functions that the buttons called were necessary to see the bug.

                       

                      To be clear, the issue was not that I got multiple buttons in the second (or third, or fourth, etc.) open document, but that I got no buttons in the second open document. Only the first documents produced any buttons, while the others didn't produce any buttons, nor had any buttons visible in the right-hand pane (and didn't have any greyed-out either).

                       

                      Strangely enough, today I am not able to replicate the problem any more. Now it functions as it did before with Acrobat DC, just like reported. My Windows 10 just updated during boot and the problem seems to be gone. Now the toolbar is again displayed as soon as I open the second document.  Among the updates was the graphics driver, and that is the only one that I can see that logically would have any affect on this (the other is a webcam driver).

                       

                      EDIT: I am able to reproduce the problem. After a reboot I opened the things I was working on an the same problem occurred. I did some trial and error tests and the problem arises only sometimes. The only sure fire way that I found to replicate that the problem is to open two (or more) pdf files (that both have the aforementioned code) at the same time. Thus when I go to explorer and select multiple files and try to open them all together.

                       

                      Once the issue has occurred, there doesn't seems to be a clear pattern that I can figure out. Sometimes the problem goes away when first opening Adobe Acrobat and using its recent file list to open multiple files one by one, but sometimes that doesn't help it. Opening one file from within Acrobat and another from explorer also sometimes seems to negate the issue.

                       

                      However, Rebooting the machine does seem to always remedy the issue, until I again open two (or more) files directly from explorer.