5 Replies Latest reply on Jun 9, 2010 11:45 AM by wildcathoya

    How to have the Comment & Markup Tool bar always display

    Jonathan R Welch

      In our marketing area, we are using a web-based Marketing Project management system to manage our copy and layout review/revisions. The tool allows users to open up the PDF from the server, and make mark ups and then post their mark ups to the server.

       

      The problem that I have is, for this functionality to work, the PDF is opened within the browser window (it has to be this way). However, when I do that, my toolbars appear differently than when I open up a PDF from my hard drive. So, my comment & markup toolbar WILL display when I open a PDF from my hard drive, but not when I open it up from my project management system in the browser window.

       

      I'm looking to have a script that will always perform the function Review & Comment > Show Comment & Markup toolbar when I open a PDF, regardless of if it's in the browser window or not.

       

      Any help is greatly appreciated!

        • 1. Re: How to have the Comment & Markup Tool bar always display
          wildcathoya Level 1

          I had the same problem and solved it, but I couldn't find a way to do it in a script.

           

          It requires a plug-in in which you do the following:

           

          1. Set a static flag "newDoc = true" in the AVDocDidOpen callback.

          2. Look for "newDoc == true" in the AVPageViewCursorProc callback.

          3, If found, then execute the following code, which will fire  AVMenuItemExecute() on the "ShowHideToolbarCommenting" menu item and expose the toolbar.

           

          if (newDoc)    {
             
          newDoc = false;
              AVDoc avDoc = AVPageViewGetAVDoc(pageView);    // pageView provided by callback
              PDDoc pdDoc = AVDocGetPDDoc(avDoc);
              AFExecuteThisScript(pdDoc, "Collab.showAnnotToolsWhenNoCollab = true;", NULL)
              BOOL bItemFound = false;
              AVMenubar avMenuBar = AVAppGetMenubar();
              AVMenu viewMenu = AVMenubarAcquireMenuByName(avMenuBar, "View");
              if (viewMenu != NULL)    {
                  AVTArraySize viewMenuItemCount = AVMenuGetNumMenuItems (viewMenu);
                  // Step through the "View" menubar items and look for the "Toolbars" submenu
                  for (AVMenuIndex i = 0; !bItemFound && i < viewMenuItemCount; i++)    {
                      AVMenuItem viewMenuItem = AVMenuAcquireMenuItemByIndex (viewMenu, i);
                      const char * pItemName = ASAtomGetString(AVMenuItemGetName (viewMenuItem);
                      if (strcmp(pItemName, "Toolbars") == 0)    {
                          AVMenu toolBarsMenu = AVMenuItemAcquireSubmenu(viewMenuItem);
                          AVTArraySize toolBarsMenuItemCount = AVMenuGetNumMenuItems (toolBarsMenu);
                          // Step through the "Toolbars" menubar items and look for "ShowHideToolbarCommenting"
                          for (AVMenuIndex j = 0; !bItemFound && j < toolBarsMenuItemCount; j++)    {
                              AVMenuItem toolsBarMenuItem = AVMenuAcquireMenuItemByIndex (toolBarsMenu, j);
                              pItemName = ASAtomGetString(AVMenuItemGetName (toolsBarMenuItem));
                              if (strcmp(pItemName, "ShowHideToolbarCommenting") == 0)    {
                                  if (AVMenuItemIsMarked(toolsBarMenuItem) == false)    {
                                      // Execute the "ShowHideToolbarCommenting" menu item
                                      AVMenuItemExecute(toolsBarMenuItem);
                                      bItemFound = true;    // Kill the loops
                                  }
                              }
                              AVMenuItemRelease(toolsBarMenuItem);
                          }
                          AVMenuRelease(toolBarsMenu);
                      }
                      AVMenuItemRelease(viewMenuItem);
                  }
                  AVMenuRelease(viewMenu);
              }
          }

           

           

          This works very reliably for me.  The "Comment & Markup" tool bar appears in the browser (IE and Firefox) as soon as the document has downloaded with no user action required.  (Note that the AVPageViewCursor event won't happen if the cursor is outside of the page view.  In that case, the user simply needs to move the cursor over the page view to fire the event and execute the code.)

           

          Bill

           

          PS - Sorry for the wordwrap; I have no control over that.

          • 2. Re: How to have the Comment & Markup Tool bar always display
            Jonathan R Welch Level 1

            Thanks Bill, This is very helpful. Just one follow up question. How do I create a plug in for this? Where do I place this plug in so that it works? Any other steps I need to take?

            • 3. Re: How to have the Comment & Markup Tool bar always display
              wildcathoya Level 1

              The SDK has sample plug-ins and documentation.   All plug-ins have certain "housekeeping" things that need to be done, so you'll want to build your plug-in around one of the samples (e.g. the "BasicPlugin" sample.)  After you compile the plugin, just drop it in the ...\Acrobat\plug_ins folder, which is a sibling of the Javascripts folder.  Alternately, have your IDE put the compiled output directly into the plug_ins folder.

               

              Plug-ins must be written in C/C++.  I use Visual Studio 2005

              .

              As discussed in "Developing Plug-ins and Applications," you'll want to register a "plug-in prefix" with Adobe, which will uniquely identify you're plug-ins and prevent naming conflicts with other plug-ins.

               

              Good luck!

              • 4. Re: How to have the Comment & Markup Tool bar always display
                Jonathan R Welch Level 1

                I hate to re-invent the wheel on this... would I be able to use the plug in you developed? I need to launch this new mark up feature to our marketing groups this week, so I doubt I have the time to create a plug in so quickly. If you would be able to share, you could e-mail it to me at: jonathan(dot)r(dot)welch(at)ampf(dot)com.

                 

                Again, many thanks!

                • 5. Re: How to have the Comment & Markup Tool bar always display
                  wildcathoya Level 1

                  Sorry, no can do.  My plug-in does a LOT more than just this and much of it is proprietary.

                   

                  You shouldn't have any problem implementing my code in the BasicPlugin sample.  I've given you about 95% of the code you'll need to add to the BasicPlugin.  You'll just need to register and implement the two callbacks for AVDocDidOpen to set the flag and AVPageViewCursorProc to execute my code.  You can debug your plugin in Firefox by attaching to the firefox.exe process.