PDF bookmarks are a must for the usability and navigability of longer documents. Without them, the browsing process can be quite painful — especially when you know that you need to skim to that crucial chapter when time is of the essence.
When these bookmarks are created programmatically, they are based on a template created using a combination of user settings and the content of the source document or web page. Since not all such documents were created with PDF bookmarks in mind, cleaning up the resulting bookmark titles can become an important part of the QA process.
- Enter ‘TEMP_Trim_Bookmarks’ as the name of the new script and click the ‘Add’ button.
- Delete any text already in the edit window and copy/paste the script below.
- Click OK to close the Script editor.
// Trim any white space at the end of bookmarks
function TrimBookmarks(bm, nLevel)
bm.name = RTrim(bm.name);
if (bm.children != null)
for (var i = 0; i < bm.children.length; i++)
TrimBookmarks(bm.children[i], nLevel + 1);
// Trims spaces at the end of a string
while (sString.substring(sString.length-1, sString.length) == ' ')
sString = sString.substring(0,sString.length-1);
return sString;var test = String.fromCharCode(144);
Originally written by ARTS PDF Product Manager Maryanne Montes in early 2005. This tip was designed to be executed via a single custom tool button using Debenu PDF Aerialist (formerly ARTS PDF Aerialist) but has been updated for general usage using Acrobat Professional X.