Skip to main content
Participating Frequently
November 2, 2016
Resuelto

Page Number of Story in IDML Document

  • November 2, 2016
  • 2 respuestas
  • 1575 visualizaciones

I require extracting the page number of the story present in IDML Document. The spread_xxx.xml has a Page tag however it is not in any way related to any particular story.

Este tema ha sido cerrado para respuestas.
Mejor respuesta de Laubender

And that deduction can be done by looking at geometric bounds of the page and figuring out whether the text frame is within those geometric bound. Am I right?

Regards,

Diwakar


Basically yes.
But I think, if objects were transformed using a transformation matrix that is not an identity matrix you first have to do the math. And that can be very hard. See for that Marc's PDFs on transformations and working with matrices.

Example:

Added a rectangle on the page. Did not move it, did not scale it, did not rotate or sheared it. Just added it and exported it to IDMS, the little brother of IDML.

Note: The value of ItemTransform is an identity matrix.

ItemTransform="1 0 0 1 0 0">

            <Properties>

                <PathGeometry>

                    <GeometryPathType PathOpen="false">

                        <PathPointArray>

                            <PathPointType Anchor="-155 -170" LeftDirection="-155 -170" RightDirection="-155 -170" />

                            <PathPointType Anchor="-155 -44" LeftDirection="-155 -44" RightDirection="-155 -44" />

                            <PathPointType Anchor="-29 -44" LeftDirection="-29 -44" RightDirection="-29 -44" />

                            <PathPointType Anchor="-29 -170" LeftDirection="-29 -170" RightDirection="-29 -170" />

                        </PathPointArray>

                    </GeometryPathType>

                </PathGeometry>

            </Properties>

Then I rotated the same rectangle to 45° and exported to IDMS again:

Now look at ItemTransform and <PathPointArray>.

ItemTransform="0.7071067811865476 -0.7071067811865476 0.7071067811865476 0.7071067811865476 48.71424945612296 -96.39339828220179">

            <Properties>

                <PathGeometry>

                    <GeometryPathType PathOpen="false">

                        <PathPointArray>

                            <PathPointType Anchor="-155 -170" LeftDirection="-155 -170" RightDirection="-155 -170" />

                            <PathPointType Anchor="-155 -44" LeftDirection="-155 -44" RightDirection="-155 -44" />

                            <PathPointType Anchor="-29 -44" LeftDirection="-29 -44" RightDirection="-29 -44" />

                            <PathPointType Anchor="-29 -170" LeftDirection="-29 -170" RightDirection="-29 -170" />

                        </PathPointArray>

                    </GeometryPathType>

                </PathGeometry>

            </Properties>

As you can see the values with <PathPointArray> did not change!
However, the position of the path points according to the page changed a lot. According to ItemTransform.

You simply cannot see by looking at the <PathPointArray> alone where the path points will be positioned.
I could have used the shear and rotate commands with InDesign and the whole object will now be outside of the page.
But its <PathPointArray> is still the same!

Some screenshots to illustrate this:

After adding a rectangle with my InDesign UI that overlaps with the page and therefore belongs to the page:

After rotating and shearing the object is outside of the page on the pasteboard:

After setting a document property, bleed, the object is counting as if positioned on the page:

For all three screenshots the <PathPointArray> will be the same.

Hope, that helps.

Regards,
Uwe

2 respuestas

Participating Frequently
November 2, 2016

I can identify the spread name by self attribute in Spread tag. But I don't think that would help much as Spread can contain multiple pages.

This is how my text frame looks like:-

<TextFrame Self="ud2" ParentStory="ud5" PreviousTextFrame="n" NextTextFrame="n" ContentType="TextType" StrokeWeight="1" GradientFillStart="0 0"GradientFillLength="0" GradientFillAngle="0" GradientStrokeStart="0 0" GradientStrokeLength="0" GradientStrokeAngle="0" ItemLayer="uba" Locked="false"LocalDisplaySetting="Default" GradientFillHiliteLength="0" GradientFillHiliteAngle="0" GradientStrokeHiliteLength="0" GradientStrokeHiliteAngle="0"AppliedObjectStyle="ObjectStyle/$ID/[None]" ItemTransform="1 0 0 1 36 -360">...</TextFrame>

And also I have a page tag in my spread XML that looks like this:-

<Page Self="uc2" Name="1" AppliedTrapPreset="TrapPreset/$ID/kDefaultTrapStyleName" AppliedMaster="uc4" OverrideList="" TabOrder=""GridStartingPoint="TopOutside" UseMasterGrid="true">...</Page>

I'm looking for a certain relation between this page tag and the text frame tag that may define this page constitute certain text frame. Am I looking in the right direction?

Community Expert
November 2, 2016

diwakarbhatt wrote:

… Am I looking in the right direction?

Basically yes.
But it will not help much.

Page items, graphic frames, text frames etc. are organized by spreads.

Long gone the times when they were organized a bit more by pages ( CS4 and below ).

Size and position of pages (the bleed area and the info area will also count, if defined) will decide if a particular page item does belong to this page or that page (or the pasteboard) on a spread. Pages can overlap as well. They can be distanced apart from each other…

In short:
InDesign's rendition of objects will decide in the end where a particular text frame will land.
You can do assumptions, but you cannot be absolutely sure by looking into an IDML file alone.

Regards,
Uwe

Participating Frequently
November 9, 2016

Hi Uwe,

Sorry for the late response. As you said that it is the redention of object that decide where the particular text frame will land and on which page. I have few questions regarding this:-

1. What exactly is redention of object? (Sorry i'm new to indesign and IDML alltogether).

2. Since rendention of object decides the page for text frame it should have some underlying logic which decides page number for the text frame. As i'm assuming that only idml file is presented as input won't it be getting the required information from idml itself?

Sorry if i'm missing something obvious, I'm a newbie.

Community Expert
November 2, 2016

Example:

A text frame defined in the spread xml is referring to a story by eg.: ParentStory="udd" .

Pick up this value and see if you can find that story amongst the story xml files.

The corresponding Story has: <Story Self="udd"

By scripting an InDesign document you could get that value if a text frame is selected:

app.selection[0].parentStory.idmlComponentName;

Result will be a String—something like this:

Story_udd

The part I bolded should be the attribute's value after exported to IDML.

Note: A particular story cannot have a page tag, because s story can consist of several containers—text frames and text paths—positioned everywhere in a document: On different pages, on different master spreads, on pasteboards and belonging to the same story.

Regards,
Uwe

Participating Frequently
November 2, 2016

Thank you for taking the time to answer the question. So if not a story can i extract page number of a particular text fragment or text frame??

Community Expert
November 2, 2016

For a text frame possibly yes.
At least you could identify on what spread the frame is positioned.

But you need a hint to identify the text frame.
Something unique perhaps. Could be a name, if it is named. Could be the size or position, if you know the size and position. And if you know some unique contents PLUS the frame is the only text container of a story you could clearly tell on what spread that frame is be positioned.

That's all a bit abstract.
But without seeing what you are seeing it's hard to tell what's the best strategy.


E.g. If you started with a print-out or an exported PDF and the InDesign document is not available and also no InDesign app is available.

Regards,
Uwe