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

Getting text from footnotes

Community Expert ,
Jun 19, 2013 Jun 19, 2013

Copy link to clipboard

Copied

Dear all,

Having managed to extract citations from ordinary paragraphs and table cells I now want to get it also from footnotes. See the complete script and test-doc (FN-11) doc here.

I get the first footnote paragraph with its citation correctly.

But my construct to get the next paragraph of the footnote obviously is wrong - there is no NextPgfInFn (or NextPgf) mentioned in the Scripting Guide, only FirstPgf and LastPgf. But it is possible to have multiple paragraphs in footnotes (see test-doc). And hence the function GetText fails for the 'second paragraph' in the footnote.

function processFootnote (fn, doc) {

// find citations in footnotes

    var fnText = "";

    var fnPara = fn.FirstPgf;

   

    while (fn.ObjectValid()) {

      fnText = (GetText(fnPara));

        alert (fnText);                    // the text of the cell

        var citations = GetTempCitations (fnText);

        var nCitations = citations.length;

        alert (nCitations + " Citations = " + citations);

    fnPara = fnPara.NextPgfInFn;                                               // <-------------- this is not valid

    }

} //--------------------------------------------------------------------------

function GetText (textObj, doc) {

  // Gets the text from the text object.

  var text = "";

  // Get a list of the strings in the text object or text range.

  if (textObj.constructor.name !== "TextRange") {                        // <--------------- Undefined is not an object

    var textItems = textObj.GetText(Constants.FTI_String);

  } else {

    var textItems = doc.GetTextForRange(textObj, Constants.FTI_String);

  }

  // Concatenate the strings.

  for (var i = 0; i < textItems.len; i += 1) {

    text += (textItems.sdata);

  }

  return text; // Return the text

} //--------------------------------------------------------------------------

What would be a valid construct to get into all paragraphs of the footnote?

And there the next question lures: does function processFootnote also handle table footnotes ?

Thanks for Your help.

Klaus Daube

TOPICS
Scripting

Views

912

Translate

Translate

Report

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

Community Expert , Jun 19, 2013 Jun 19, 2013

Hi Klaus,

Use NextPgfInFlow

Rick

Votes

Translate

Translate
Community Expert ,
Jun 19, 2013 Jun 19, 2013

Copy link to clipboard

Copied

Hi Klaus,

Use NextPgfInFlow

Rick

Votes

Translate

Translate

Report

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 Expert ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

Thank You, Ric, that worked.

However, i had to add a 'stop', because an endless number of empty footnotes were found.

function processFootnote (fn, doc) {
// find citations in footnotes
     var fnText = "";
     var fnPara = fn.FirstPgf;
     
     while (fn.ObjectValid()) {
       fnText = (GetText(fnPara));
       if (fnText == ""){ return; }       // <----------------- prevent runaway
          alert (fnText);                    // the text of the footnote
          var citations = GetTempCitations (fnText);
          var nCitations = citations.length;
          alert (nCitations + " Citations = " + citations); 
    fnPara = fnPara.NextPgfInFlow;
     }
} //--------------------------------------------------------------------------

Votes

Translate

Translate

Report

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 Expert ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

Hi Klaus, The code in your function is not quite right. The way I understand it, you are using the processFootnote function to process a single footnote. If that is the case, then this line:

while (fn.ObjectValid()) {

is not correct. The fn object will always be valid and that is why you have a runaway loop. You need this instead:

while (fnPara.ObjectValid()) {

This code will be unnecessary:

if (fnText == ""){ return; }

Rick

Votes

Translate

Translate

Report

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 Expert ,
Jul 02, 2013 Jul 02, 2013

Copy link to clipboard

Copied

LATEST

Thanks Rick - this solved the problem.

Now I'm able to collect the citations in

- ordinary paragraphs,

- table cells

- foot notes

- table foot notes.

For the purpose of my project I postpone looking into textframes in anchored frames and other constructs (something must be left for later enhancements...)

Votes

Translate

Translate

Report

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