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.
Luckily, JavaScript can vastly simplify the process. Using the sample code below, you can iterate through a document's bookmarks, renaming them and trimming off any trailing white space. As always, this code can either be used "as-is" to reproduce the process in its entirety or mixed and matched with other code samples to perform different functions. For instance, one such modification could involve getting the JavaScript to go through and print the bookmark names to create a report.
Note:
Although I originally wrote this to be executed via a custom tool button using ARTS PDF Aerialist, you can also execute it from Acrobat Professional's JavaScript debugger.
// Trim any white space at the end of bookmarks
function TrimBookmarks(bm, nLevel)
{
bm.name = RTrim(bm.name);
console.println(bm.name);
if (bm.children != null)
for (var i = 0; i < bm.children.length; i++)
TrimBookmarks(bm.children[i], nLevel + 1);
}
TrimBookmarks(this.bookmarkRoot, 0);
// Trims spaces at the end of a string
function RTrim(sString)
{
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;var test = String.fromCharCode(144);
}
Despite the numerous benefits, there can be potential issues with the conversion of paper documents into electronic archives. When scanning paper pages into PDF, it's possible to end up with the odd- and even-numbered pages in separate PDF files. It can be very time-consuming to collate them manually, but there is an easier way. Sean Stewart explains.
BCL easyPDF SDK is a set of PDF Programming Libraries designed specifically to help Software Developers / Programmers build and deploy enterprise class PDF applications for corporate wide PDF...