Skip to main content
Participating Frequently
March 23, 2010
Question

Difference between a story and a layer in InDesign document

  • March 23, 2010
  • 1 reply
  • 2581 views

The backgound is that I am developing C# application using InDesign apis to get InDesign content. Now I am facing a problem that I do not want to extract the content from invisible layers. But the application was using Story related objects (Story -> Paragraph) to get InDesign content. I tried to use Layer's parent Story id as the filter condition but the content extracted does not decrease much. The expected result should be the same as when I delete one layer but the actual result is more content is extracted when the layer exists but invisible.

Does anybody have an idea about this? Or giving me the difference between a story and a layer (what is the text content difference between them) will be much appreciated.

This topic has been closed for replies.

1 reply

Kasyan Servetsky
Brainiac
March 23, 2010

I don't know C# but can illustrate my idea in JS:

var myStory = app.activeDocument.stories[0];
var my1stTextFrame = myStory.textContainers[0];
var myLayer = my1stTextFrame.itemLayer;
if (myLayer.visible) {
     alert("The story is on visible layer");
}
else {
     alert("The story is on invisible layer");
}

All stories are contained by a single textframe/chain of text frames (or text path(s)) which has/have ItemLayer property referencing to the layer they are on. You can check the layer's visible property to find out if it's hidden or not. However this example doesn't deal with cases when text frames are nested or grouped, but this can be solved as well.

Kasyan

Harbs.
Brainiac
March 23, 2010

Just please realize that a story can be threaded across different layers...

Harbs

Participating Frequently
March 24, 2010

Thanks for your answers. Another question: how can I use a layer object to get all the text content under this layer using C#? Is there anybody who has some experience on this? Much appreciated.

Here is my sample code by C#:

            foreach (InDesign.TextFrame t in layer.TextFrames)
            {
                for (int i = 0; i < t.Paragraphs.Count; i++)
                {
                    if (i == 0)
                    {
                        paragraph = (InDesign.Paragraph)t.Paragraphs.FirstItem();
                    }
                    else
                    {
                        paragraph = (InDesign.Paragraph)t.Paragraphs.NextItem(paragraph);

                    }

             }

by above code, the paragraphs count is 0, but the layer I tested with the document does have text content.

Looking forward to your suggestions.