0

I'm new to IDML document and was wondering how can one find the page number of a particular story. Spread_XXXX.xml has Page elements which basically describes how many pages are in spread and TextFrame which references to the story. However, I could not find any link between them.

  • I don't know IDML (I use InDesign), but a cursory examination of the spec seems to indicate that IDML separates layout from content. That would mean that the the page on which something appears is not known until the content is rendered within the defined layout. – Jim Garrison Oct 25 '16 at 04:57
  • but won't content rendering be using some underlying logic to map stories to the particular page number and render them accordingly? – Diwakar Bhatt Oct 25 '16 at 05:26
  • Yes, and you'd have to duplicate that logic as the result is not stored in the IDML file. – Jim Garrison Oct 25 '16 at 15:06

1 Answers1

0

I know I'm kind of late to the party, but maybe the answer will be helpful to someone else.

While your train of thoughts is kind of correct (a text frame is on a page), the reality in InDesign/IDML is completely different. The actual dependency looks as follows (simplified):

Document:
|
|-Spread
  |
  |-Page
  |-Page
  |-TextFrame
  |-TextFrame
  |-Rectangle... and so on

As you can see a text frame is no a child of a page but a spread. It's relative to spread's coordinate system.

And it kind of makes sense. Image you have a layout like this:

|________Spread___________|
|___Page 1___|___Page 2___|
|       |__Text 1__|      |
|       |          |      |
|       |__________|      |
|____________|____________|

The question is: On which page is Text 1? You can't really answer that question. All you could do is to figure out if a corner of a text frame is within the bounding box of a specific page.

Quoting the IDML cookbook:

By default, Page items are in spread coordinates. The origin lies at the center point of the page binding. Often, it is easier to work in page coordinates. This can be achieved in IDML by adjusting the page item’s ItemTransform matrix. Conceptually, this is a matter of moving the origin from the spread center point to the top-left corner of the page, as follows:

  1. Determine the zero-based page binding location, as described above.
  2. Determine the zero-based page index.
  3. Determine the page width.
  4. Determine the page height.
  5. Calculate the x (or horizontal) translation as follows: xTranslation = (pageIndex - pageBinding) * pageWidth
  6. Calculate the y (or vertical) translation as follows: yTranslation = pageHeight / 2
  7. Add yTranslation.

For example, the following TextFrame is on a page just to the left of the binding; therefore, it is transformed horizontally -612 points and vertically -396 points. This moves the origin from the center of the binding to the left 612 points and up 396 points.

<TextFrame ... ItemTransform="1 0 0 1 -612 -396">
...
<PathPointArray>
<PathPointType Anchor="36 36" LeftDirection="36 36"
RightDirection="36 36"/>
...
Aleksander Wons
  • 3,611
  • 18
  • 29