4 Replies Latest reply: Apr 21, 2011 10:20 AM by s_stuff RSS

    How to set Bookmark element to expand

    s_stuff Community Member

      Hi All,

       

      First I'll explain the solution so that you understand what I'm trying to accomplish.

       

      The solution involves several PDF files and each one is linked by the bookmark using the following DDX:

       

      <Bookmark>    
          <Action>    
                <Launch NewWindow="true">     
                     <File Name="MyFile.pdf"/>    
                </Launch>   
           </Action>   
           <Title>Contents</Title>  
      </Bookmark>

       

      Each PDF file will contains the same bookmark hierarchy data which consist of several levels, therefore they contain the links to the other PDF files.  Each time one of the bookmark element is clicked the bookmark resets back to it's orginal state of collapsed since it is opening a new pdf file.

       

      I'm trying to dynamically assemble a bookmark.xml file with a pdf document.  There are two things I want to accomplish through the bookmark.xml:

       

      1.  Set one specific bookmark element to expanded when it's rendered

      2.  Set the focus (or highlight) a specific bookmark element when it's rendered.

       

      Basically each time a bookmark item is clicked I want to maintain the user's last selected bookmark item to be expanded when the new pdf file is displayed.

       

      I've attached a sample pdf file in which I can manipulate the expanding and collapsing of the bookmark via javascript, I need to figure out how to do this via the xml file that defines the bookmark hierarchy and functions, since the bookmark is merged with the PDF via the Assembler DSC service.

       

      Is this possible?  If yes what xml tag would accomplish this?  Please provide any suggestion or alternative solution.  Currently I have two alternative solution (html or flex UI) but this involves additional depencies outside of LiveCycle, I'd like to create a solution that is completely Adobe LiveCycle.

       

      Thanks,

      s_stuff

        • 1. Re: How to set Bookmark element to expand
          s_stuff Community Member

          Perhaps as a workaround I could insert javascript into the resulting pdf.

           

          I want to insert the following script:

           

          function CollapseExpand(bkm, nLevel, bookmarkNm){

              var s = "";

              for (var i = 0; i < nLevel; i++) s += " ";

             

              if (bkm.children != null){

                  for (var i = 0; i < bkm.children.length; i++) {

                      if (bkm.children[i].name == bookmarkNm){               

                          if (bkm.children[i].open == 1)  bkm.children[i].open = 0;

                          else                            bkm.children[i].open = 1;

                      }

                      CollapseExpand(bkm.children[i], nLevel + 1, bookmarkNm);

                  }

              }

          }

           

          The Adobe DDX reference mentions this:

           

           

          <PDF result="resultDoc">

                  <PDF source="pdf1"/>

                  <JavaScript source="js1", name="onOpen"/>

          </PDF>

           

          I’m not sure if I can put the entire function code to replace js1.  Is this workaround doable.  How can I insert javascript via ddx? 

          • 2. Re: How to set Bookmark element to expand
            senthil_lcasm

            You cannot insert the javascript code directly in a ddx. The javascript should be present in an input stream/file.

             

             

            The DDX would look more like this.

             

            <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
              <PDF result="Untitled 1">
                <PDF source="sourcePDF1"/>
               <JavaScript source="Js1" name="anyUniqueName "/>
              </PDF>
              <?ddx-source-hint name="sourcePDF1"?>
            </DDX>

             

            Where,

            The sourcePDF1 is the input PDF file

             

            The Js1 is any input stream which contains the javascript. For example it can be a .txt file which contains the javascript that needs to be inserted into the resultant pdf.

             

            "I’m  not sure if I can put the entire function code to replace js1.  Is this  workaround doable.  How can I insert javascript via ddx? "

             

            So to answer your question,

             

            1) Create a file with the javascript code in it

            2) Use the javascript tag to pass the 'file with the javascript code'.

             

            The resultant file will contain the javascript code. Call the javascript code to expand the bookmarks.

            • 3. Re: How to set Bookmark element to expand
              s_stuff Community Member

              Thank you senthil_lcasm, your response was helpful.

               

              I now have another problem with this workaround solution.  I've successfully inserted the javascript below via ddx through Adobe LiveCycle Assembler service, but now this line bkm.children[i].open = true; or bkm.children[i].open = 1; fails to execute.  The bookmark isn't expanded and I do get the "Match Found ..." message.  This same line of code works fine in the form I create via Form Designer ES2 but fails in this situation.

               

              app.alert("Expanding ...");

              ExpandBkm(this.bookmarkRoot, 0, "1.0 Engagement Setup");     
              function ExpandBkm(bkm, nLevel, bookmarkNm){
              if (bkm.children != null){
                for (var i = 0; i < bkm.children.length; i++) {  
                 if (bkm.children[i].name == bookmarkNm){   
                  bkm.children[i].open = true;
                  app.alert("Match Found ... " + bkm.children[i].name + " is open? " + bkm.children[i].open);
                  break;
                 }
                 ExpandBkm(bkm.children[i], nLevel + 1, bookmarkNm);
                }
              }
              }

              Does anyone have any suggestion to fix this latest problem?

               

              Also when I checked against this doc http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf the open method is only readable in Reader.  If this is true than this solution will not work for me.

              • 4. Re: How to set Bookmark element to expand
                s_stuff Community Member

                I recieved a patch from Adobe for this.