Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[CS2][JS]Superscript to Footnotes

Community Beginner ,
Jul 09, 2009 Jul 09, 2009

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

TOPICS
Scripting
4.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jul 09, 2009 Jul 09, 2009

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.parentStory.footnotes.add(LocationOptions.BEFORE, arrFN.insertionP

...
Translate
Valorous Hero ,
Jul 09, 2009 Jul 09, 2009

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.parentStory.footnotes.add(LocationOptions.BEFORE, arrFN.insertionPoints[0]);

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

}

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

Kasyan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 09, 2009 Jul 09, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 10, 2009 Jul 10, 2009

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.parentStory.footnotes.add(LocationOptions.BEFORE, arrFN.insertionPoints[0]);

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

}

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

app.findGrepPreferences.position = Position.SUPERSCRIPT;

app.changeGrepPreferences.changeTo = "";

myDoc.changeGrep();

Kasyan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 10, 2009 Jul 10, 2009

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.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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 10, 2009 Jul 10, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2009 Jul 11, 2009

Ok thanks Kasyan, always.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 11, 2009 Jul 11, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2009 Jul 11, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 12, 2009 Jul 12, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 12, 2009 Jul 12, 2009

sent file to your yahoo mail. thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 12, 2009 Jul 12, 2009

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;
    myPars = myText.paragraphs;
    for (j = 0; j < myPars.length; j++) {
        myPar = myPars;
        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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 13, 2009 Jul 13, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2010 May 06, 2010

Thanks man! Works well in CS4!


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2011 Aug 09, 2011
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines