Skip navigation
MaxineY
Currently Being Moderated

Bookmarks - Sentence Case

Apr 17, 2012 5:49 AM

Tags: #java #acrobat #pdf #change #scripting #case #bookmark #configure #sentence #tweaking

Hi

 

Ok, so I've searched the forums and have come really really close, but just need a bit of help tweeking here ...
I would like to change the bookmarks in Acobat PDF to Sentence case.
eg: tommy went to the well > Tommy went to the well

 

Searching through the forums I found this great piece of scripting that converted everything to lower case:

 

function DumpBookmark(bm, nLevel)

{

var s = "";

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

    if (nLevel >0){

      s= bm.name;

      bm.name = s.toLowerCase();

      }

    if (bm.children != null)

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

      DumpBookmark(bm.children[i],nLevel+1);

}

DumpBookmark(this.bookmarkRoot, 0);

 

 

 

HTH, Reinhard

 

 

That worked great - but to go through all the bookmarks to change the first letter is proving to be a bigger mission then I anticipated. Can anyone assist in tweaking the above coding so that it converts to Sentence case, or perhaps provide another solution?

 
Replies
  • Currently Being Moderated
    Apr 20, 2012 11:13 AM   in reply to MaxineY

    [ moved to the correct forum ]

     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Apr 20, 2012 12:23 PM   in reply to MaxineY

    Either:

     

    bm.name = s.slice(0, 1).toUpperCase() + s.slice(1);

     

    or:

     

    bm.name = s.slice(0, 1).toUpperCase() + s.slice(1).toLowerCase();

     

     

    depending on what you want.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points