5 Replies Latest reply on Feb 13, 2016 9:38 PM by TᴀW

    C# Get Text from Larger Text


      Below is an example C# code to put in Content to a paragraph.


                  InsertionPoint ip = textFrame.ParentStory.InsertionPoints[-1];
                  ip.Contents = "This is an InDesign Table conversion test: Header1\tHeader2\rCell1\tCell2";
                  Text text = ip.Texts.FirstItem();


      What I want to figure out is how would I extract the right part of the text starting after the ":"?
      I want to extract it as a "Text" object, or any other compatible object so I could use the function "ConvertToTable".

      Text subText = ...//Somehow get the the text after the ":"
      Table aTable = subText.ConvertToTable("\t", "\r");


      So using C# text.ItemByRange(x,x) doesn't really work since it returns a InDesign "Objects" in C#, which is basically an array.
      The "Objects" doesn't have a "ConvertToTable" method.

      The "Objects" class has below properties and methods:




      Doesn't seem like there's a way to convert a collection of "Objects" to a "Text" object.
      I've tried to convert "Objects" to "Text" as the following, but it fails on me:

      Objects objects = text.Characters.ItemByRange(43, -1);
      Text subText = (Text)objects;