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:
Result will be a String—something like this:
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.
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??
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.
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?
diwakarbhatt wrote:… Am I looking in the right direction?
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…
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.
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.
It's not obvious at all, if you are new to InDesign, to Scripting InDesign and to IDML to understand some hierarchies and dependencies in the DOM. The document object model is complex and sometimes defies logic. Or at least defies common sense. Depends on the perspective you are looking at it, if your experience with InDesign is more from the user's or the developer's side.
With "rendition" of objects I mean the interpretation of InDesign where objects are positioned.
And what according to other factors, "formatting" through several preferences and property/value pairs, can be actually seen on the screen when a document is opened, when an IDML file is re-interpreted by a given version of inDesign.
A document consists of spreads.
Spreads are organizing pages.
The position and size of a page on a given spread can be arbitrary. Yes, arbitrary. And if a document on document level is "facing pages" could even influence "bouncing" of pages and page items. Even if the numbers in IDML say different things.
From IDML's perspective, looking into several XML files, you can only deduce on which page a page item on a spread will land. You cannot tell for sure. Depending on the version of InDesign that is opening the IDML file, this could be quite different.
If you want to work yourself into the complex matter of dependencies and the grand view of geometry of documents and page items I recommend to have a look at Marc Autret's exceptional CoordinateSpacesTransfos01-03.pdf here:
2. InDesign Coordinate Spaces
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?
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.
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.
How can we find the page coordinates into the spread coordinates system?
Currently "GeometricBounds" attribute of page is having the coordinates information for page's inner coordinate system. I want to calculate the coordinates of page in spread coordinate system. And what is the impact of "MasterPageTransform" attribute of page on this calculation.
I think, you can find the (complex) answer with Marc Autret's researches on "Coordinate Spaces & Transformations".
Chapter 4. Resolving Locations
Quoting Marc Autret:
Many technical details had to be discussed in the previous chapters but our efforts will be rewarded! We can now tackle the very first practical questions that arise in terms of InDesign geometry: how to specify or identify a location in a document. This seemingly simple problem requires, once again, a bit of meticulousness.
Together with the three chapters before:
And here is another problem case where to ask, if a certain pageItem is positioned on a particular page cannot be answered clearly without the question.
Who do we ask this question?
1. The pageItem?
2. The document?
3. An exported PDF perhaps?
Case: The document consists of 3 pages with one single rectangle placed and selected on page 1.
However the position of all the three pages on the spread is the same.
( Easily pages can be moved by the Page Tool )
1. If we ask the selected pageItem by scripting on what page it is positioned:
Then the number 0 is returned that indicates the index of the first page in the document.
Well, that's one answer.
2. If we ask the document by scripting about how many page items are in the document:
Then the number 1 will be returned.
If we then access that single item and ask on what page it is positioned from the document's perspective
The answer will be the same as in case 1. It's positioned on page 1 of the document that has index 0.
3. But if we export all pages of the document to PDF, every page will contain the rectangle!
The Pages panel will give a hint on this: