title: Sort Acrobat XI Pro Bookmarks with Adobe's JavaScript
body: <p>I have a large Acrobat file (Acrobat XI Pro) which I have Bookmarked.  The resulting Bookmarks are, however, all over the map so the goal is to sort the Bookmarks A-Z.  I searched for an appropriate Acrobat Action without success.  I did, however, locate some possible JavaScript in the the Acrobat XI SDK:</p>
  
  <pre><code> http://www.adobe.com/devnet/acrobat.html
  </code></pre>
  
  <p>I downloaded it (at bottom of EULA for version XI):</p>
  
  <pre><code> http://www.adobe.com/devnet/acrobat/sdk/eula.html
  </code></pre>
  
  <p>I found a reference on batch sequences with three sections of interest: (1) Gather bookmarks to an array; (2) Sort Bookmark subroutine; and (3) Copy bookmarks from an array.</p>
  
  <p>Ideally I would like to combine all scripts into a single JavaScript call in the Action.  My first attempt was to create an Action with two separate JavaScript calls (1) as the GATHER and (2) &amp; (3) as the COPY with the SORT integrated</p>
  
  <p>The first JavaScript compiles after I put the script into the JavaScript call in the Action.  However, the second JavaScript would not compile.  The error was an "unterminated string literal" at this line of code:
            +'var that =
                 app.openDoc("'+ global.bmArray[i][1]+'.pdf",  [ERROR PRESENTS HERE]
                      this);\r\t'
            +'if ( this != that ) this.closeDoc();\r'</p>
  
  <p>I researched this error online and tried various solutions without success.</p>
  
  <p>When I failed with building within an Action, I took the put the two JS scripts – the Gather and the Sort - into a .txt file and saved it as a .sequ which, when , should automatically populate into Acrobat as an Action.  When I did this Acrobat reported it as corrupt and unloadable so that didn't work either.</p>
  
  <p>My hope is a review of Adobe’s code with a solution to the unterminated string literal error a guide that the location guidance on the insert location of the SORT into the COPY part of the script.</p>
  
  <p>My goal, as noted, is to have an Action that merely re-sorts the Bookmarks.  The JavaScript I found seems to fit the bill as it marks the Bookmark links to the respective document.  If I am incorrectly reading this and could be steered in the right direction, it would be appreciated.</p>