5 Replies Latest reply on Apr 3, 2010 3:44 PM by PeterPow

    Footnotes contents

    PeterPow Level 1

      Hello Guys,

       

      I'm facing a problem with footnotes. When using the "contents"-property the special characters like footnote numbering, suffixes and prefixes are returned withing the footnote text. How is it possible to retrieve only the "real" text of the footnote without this special characters?
      Thanks in advance!

        • 1. Re: Footnotes contents
          Peter Kahrel Adobe Community Professional & MVP

          Try disabling the footnote numbering setting in the options. Check the document.footnoteOptions

           

          Peter

          • 2. Re: Footnotes contents
            PeterPow Level 1

            Thanks for your answer!

             

            Disabling it is of course possible but it does not affect already existing footnotes, only newly created ones. So if I try to read the text of an existing footnote your way is not an option.

            • 3. Re: Footnotes contents
              [Jongware] Most Valuable Participant

              You are partly wrong -- only the footnote number placeholder is returned in the "contents"; it does not contain the suffix and prefix. These are encapsulated inside the number placeholder code itself.

               

              It does contain that number code (Unicode character 4), followed by the Separator text as defined in the Document Footnote options. However, some care is necessary, because it's possible to manually edit this text in the footnote itself. It's even possible to remove the number code itself as well, so the last thing you'd want is simply "removing x characters" from the start of the string.

               

              This ought to work: grab the contents, inspect if the first character is the number code, and if so, compare the stuff right after it with the original Footnote Separator text. If it's exactly the same, remove it from your version; if not, you better leave whatever is there.

               

              That would look like:

               

              myFootnote = app.activeDocument.stories[0].footnotes[0];
              contents = myFootnote.contents;
              
              sep = app.activeDocument.footnoteOptions.separatorText;
              if (sep.length && contents.charCodeAt(0) == 4 && contents.substr(1,sep.length) == sep)
              contents = contents.substr(sep.length+1);
              alert ("["+contents+"]");
              

              • 4. Re: Footnotes contents
                [Jongware] Most Valuable Participant

                That'd better be changed to this: first remove the footnote number, and then check for the separator text, because this is optional:

                 

                myFootnote = app.activeDocument.stories[0].footnotes[0];
                contents = myFootnote.contents;
                
                if (contents.charCodeAt(0) == 4)
                {
                     contents = contents.substr(1);
                     sep = app.activeDocument.footnoteOptions.separatorText;
                     if (sep.length && contents.substr(0,sep.length) == sep)
                          contents = contents.substr(sep.length);
                }
                alert ("["+contents+"]");
                

                 

                 

                You might still run into problems where someone edited the note and inserted something before the note number code ..

                • 5. Re: Footnotes contents
                  PeterPow Level 1

                  This seems to work, thank you!