6 Replies Latest reply on Jan 27, 2014 9:13 AM by gert verrept

    convert text to footnote

    gert verrept Level 2

      8.      de chercher plus de véritables [1] partenariats avec la société civile afin que les défenseurs des droits de l'homme se sentent pleinement [2] soutenus par l'UE;


      [1] HRW: Central Asia : Five Years of EU engagement

      [2] http://www.senat.fr/rap/r96-2013,1054/r96-374.html.


      This is a little sample of xml-text we get from external sources. There's no link between the false "footnote-ref [1]" in de text and the false "endnote text".

      Is there a possibility to convert those "notes" to real notes in de text, but not to end-notes? Sometimes these kind of notes extend to more than 100.



        • 1. Re: convert text to footnote
          Peter Kahrel Adobe Community Professional & MVP

          If you can identify uniquely the references in the text ([1], [2], etc) and the notes/note numbers, then yes.

          • 2. Re: convert text to footnote
            gert verrept Level 2

            Yes, the structure is always the same. We get [1] in the text and at the end of the complete story the [1] followed by the footnote text. All footnotes are numbered from [1] till ...

            • 3. Re: convert text to footnote
              Peter Kahrel Adobe Community Professional & MVP

              That was clear from your first post. My question was: is every number in brackets in the text a footnote reference?; and is every number in brackets at the start of a paragraph a footnote number?

              • 4. Re: convert text to footnote
                gert verrept Level 2

                Sorry, misunderstood your question, but indeed, every number between [ ] is a footnote reference and every [ ] at the start of a para is a footnote number.

                • 5. Re: convert text to footnote
                  Jump_Over Level 5



                  Just to show the way:

                      myDoc = app.activeDocument,
                      mStory = myDoc.textFrames.item("story").parentStory,
                      mEndNotes = myDoc.textFrames.add( {name:"EndNotes"} ),
                      k, len, cIP, currPara, currFoot, mMarkers;
                  app.findGrepPreferences = app.changeGrepPreferences = null;
                  // edit doc.footnoteOption here
                  with (myDoc.footnoteOptions) 
                      showPrefixSuffix = FootnotePrefixSuffix.PREFIX_SUFFIX_BOTH;
                      prefix = "[";
                      suffix = "]";
                      separatorText = "\t";
                      markerPositioning = FootnoteMarkerPositioning.NORMAL_MARKER;
                  // move endnotes to a separate textFrame
                  for (k=mStory.paragraphs.length - 1; k >=0; k--) 
                      if (mStory.paragraphs[k].contents.search(/^\[\d+\]/) == 0) 
                          currPara = mStory.paragraphs[k].move(LocationOptions.AT_BEGINNING, mEndNotes.parentStory);
                  // create footnote markers
                  app.findGrepPreferences.findWhat = "\\[\\d+\\]";
                  mMarkers = mStory.findGrep();
                  len = mMarkers.length;
                  while (len-->0) {
                      cIP = mMarkers[len].insertionPoints[0].index;
                      mStory.footnotes.add( LocationOptions.AFTER, mStory.insertionPoints[cIP] );
                  // fill footnote contents with proper text
                  for (k=0; k < mStory.footnotes.length; k++) {
                      currFoot = mStory.footnotes[k];
                      mEndNotes.paragraphs[0].texts[0].move(LocationOptions.AT_END, currFoot.texts[0]);
                      if (mStory.footnotes[k].characters[-1].contents == "\r") mStory.footnotes[k].characters[-1].remove();



                  • both text and endnotes are in the same story
                  • one of this story's textContainer is named "story"
                  • each endnote is a separate (one) paragraph
                  • initially there is a white space after endnote's number



                  • 6. Re: convert text to footnote
                    gert verrept Level 2

                    Perfect. Just had to change "story" to our frame names, we use two frames, a Dutch and a French one (2 frames side by side), and run the script twice.

                    Thanks a lot Jarek.