14 Replies Latest reply on Aug 9, 2011 4:24 AM by M Karthik

    [CS2][JS]Superscript to Footnotes

    chrlsdrwn12 Level 1

      Hello scripters,

       

      I converted a scanned pdf to doc and then load in inDesign my problem is the footnotes became superscript numbers.

      Is there any way we can convert superscript numbers to footnotes in InDesign?

       


      Thanks,

      CharlesD

        • 1. Re: [CS2][JS]Superscript to Footnotes
          Kasyan Servetsky Level 5

           

          I'm not sure that I properly understand what you need — it's difficult for me to do this, without seeing your file. I assume that you have inclusions of text in superscript and want to convert every such a text range into a separate footnote.

           

           

          app.findTextPreferences.position = Position.SUPERSCRIPT;

          app.changeTextPreferences.changeTo = "";

          arrFN = app.documents[0].findText(true);

           

          for (i=0; i<arrFN.length; i++) {

                myFN = arrFN[i].parentStory.footnotes.add(LocationOptions.BEFORE, arrFN[i].insertionPoints[0]);

                myFN.texts[0].insertionPoints[-1].contents = arrFN[i].contents.substr(1);

          }

           

           

          This is not the final solution, just to show you approach. The original superscript text still sould be removed.

           

           

          Kasyan

          • 2. Re: [CS2][JS]Superscript to Footnotes
            chrlsdrwn12 Level 1

            Thanks Kasyan.

             

            To show a clearer view, we have this scanned book that we have to recreate in indesign and do some modifications in the text. so we convert the scanned pdf to doc file and then load the doc in indesign. The problem with footnotes is that they became part of the text not as real footnotes. so i have to find all the superscripted digits then remove them and insert footnotes manually. then copy and paste the contents to the footnotes frame. if there are 300 footnotes in 1 file it takes years to accomplish this task.

             

            The script you just wrote works perfectly in CS3 (some errors in CS2), i just have to delete the last line. I got what i needed. But if only we could automatically remove the original superscript digits and place the text range into separate footnotes that would be really really great.

             

            - CharlesD

            • 3. Re: [CS2][JS]Superscript to Footnotes
              Kasyan Servetsky Level 5

              Hi Charles,

               

              Here is a new version of the script, it removes original superscript text and retains footnote references. I forgot to mention yesterday that this script is for CS3; I don't have CS2 any more. And since it uses GREP, you just can't do this in CS2.

               

              myDoc = app.activeDocument;

              app.findTextPreferences.position = Position.SUPERSCRIPT;

              arrFN = myDoc.findText(true);

               

              for (i=0; i<arrFN.length; i++) {

                    myFN = arrFN[i].parentStory.footnotes.add(LocationOptions.BEFORE, arrFN[i].insertionPoints[0]);

                    myFN.texts[0].insertionPoints[-1].contents = arrFN[i].contents.substr(1);

              }

               

              app.findGrepPreferences.findWhat = "(?<=~F)(.+)";

              app.findGrepPreferences.position = Position.SUPERSCRIPT;

              app.changeGrepPreferences.changeTo = "";

              myDoc.changeGrep();

               

              Kasyan

              1 person found this helpful
              • 4. Re: [CS2][JS]Superscript to Footnotes
                chrlsdrwn12 Level 1

                Hi Kasyan,

                 

                It works great! It saved me thousands of working hours.

                I just have to delete this line though:

                 

                myFN.texts[0].insertionPoints[-1].contents = arrFN[i].contents.substr(1);

                 

                It says its not a function.

                 

                Is there a way we can also put the appropriate text in those footnotes? so i don't have to cut and paste them.

                 

                - CharlesD

                • 5. Re: [CS2][JS]Superscript to Footnotes
                  Kasyan Servetsky Level 5

                  The script works for me on CS3 for PC. The line you removed inserts text into footnotes – without it the script will not work as intended.

                  • 6. Re: [CS2][JS]Superscript to Footnotes
                    chrlsdrwn12 Level 1

                    Ok thanks Kasyan, always.

                    • 7. Re: [CS2][JS]Superscript to Footnotes
                      Kasyan Servetsky Level 5

                      Did it work for you or not? Can you switch over to CS3/4? I just can't help you with CS2: it doesn't support GREP and I don't have it installed.

                      • 8. Re: [CS2][JS]Superscript to Footnotes
                        chrlsdrwn12 Level 1

                        I have CS3 i tested it and it worked. The only problem is i have to delete the line i mentioned above. because the error says its not a function. so when i removed it, the script actually worked. it replaces the superscript numbers to real footnotes. i just have to manually cut and paste the contents to footnotes accordingly.

                        • 9. Re: [CS2][JS]Superscript to Footnotes
                          Kasyan Servetsky Level 5

                          Could you send me or post a zipped sample file, so that I could see what's going on? My e-mail is askoldich@yahoo.com

                          • 10. Re: [CS2][JS]Superscript to Footnotes
                            chrlsdrwn12 Level 1

                            sent file to your yahoo mail. thanks.

                            • 11. Re: [CS2][JS]Superscript to Footnotes
                              Kasyan Servetsky Level 5

                               

                              Hi Charles,

                               

                              The difficulty is that footnotes imported from your doc-file are not formatted in superscript. They partially formatted with 9 points size,  partially with 10, so it's difficult to differentiate them from the main text.

                              I offer you to do the following approach:

                              1 Create a paragraph style "Fnote" and assign it a different color – e.g. blue (Footnotes-1a.indd)

                              2 Apply "Fnote" style to footnote text:

                              Go to find/Change > GREP and select these options

                              Find What: .+$

                              Find Format: size 9 pt

                              Change Format: paragraph style "Fnote"

                              Click Change All (Footnotes-1b.indd)

                              3 Run the script

                              Now you have to manually move footnote references (in blue) to their original positions (in black).

                              This solution is far from perfect: not all text is converted to footnotes, not all original text is removed. To make it perfect would require a day, two or more of work, but I have no time for this.

                               

                               

                              Kasyan

                               

                              myDoc = app.activeDocument;
                              app.findTextPreferences = app.changeTextPreferences = null;
                              app.findTextPreferences.appliedParagraphStyle = "Fnote";

                               

                              myTexts = myDoc.findText();

                               

                              for (i = 0; i < myTexts.length; i++) {
                                  myText = myTexts[i];
                                  myPars = myText.paragraphs;
                                  for (j = 0; j < myPars.length; j++) {
                                      myPar = myPars[j];
                                      myFN = myPar.parentStory.footnotes.add(LocationOptions.BEFORE, myPar.insertionPoints[0]);
                                      myFN.texts[0].insertionPoints[-1].contents = myPar.contents.substr(0, myPar.contents.length-1);
                                  }
                              }

                               

                              app.findTextPreferences = app.changeTextPreferences = null;

                               

                              app.findGrepPreferences = app.changeGrepPreferences = null;
                              app.findGrepPreferences.findWhat = "(?<=~F)(.+)";
                              app.findGrepPreferences.appliedParagraphStyle = "Fnote";
                              app.changeGrepPreferences.changeTo = "";
                              myDoc.changeGrep();
                              app.findGrepPreferences = app.changeGrepPreferences = null;

                               

                              alert("Done");

                               

                              P.S. The attachment got stuck in the forum, as usual. I'll send it to you by e-mail.

                              1 person found this helpful
                              • 12. Re: [CS2][JS]Superscript to Footnotes
                                chrlsdrwn12 Level 1

                                I'll give it a try. Thank you very much for spending time with this one.

                                • 13. Re: [CS2][JS]Superscript to Footnotes
                                  BenCloutier Level 1

                                  Thanks man! Works well in CS4!


                                  • 14. Re: [CS2][JS]Superscript to Footnotes
                                    M Karthik Level 1

                                    Hi All,

                                     

                                    My indesing file is double column with footnote. As per the layout option each column is having the footnote. Now my author wants all footnotes to a single column. Please help me how to do this. I am using indesign CS2

                                     

                                    Thanks

                                    Karthik