Skip to main content
Participant
February 26, 2014
Question

[CS6] IGeometry of page return bounds different than seen in UI

  • February 26, 2014
  • 1 reply
  • 639 views

Hello all,

I'm running into this weird issue and hope someone could help shining some insights over.

For CS6, we have a plugin that needs to read the page bounds in page coordinates, and we have been using the below code to get it

InterfacePtr<IGeometry> pageGeometry(pageHierarchy, UseDefaultIID());

PMRect bounds = pageGeometry->GetBoundingBox(Geometry::PathBounds());

However, we have dicovered that when we resize the page(s) via "Document Setup" (our document has "Facing Pages" unchecked), the bounds we got from the code above no longer matches what being seen in the UI. E.g. if we enlarge the page size, the left and top values got from the code would be negative, where the UI shows that the page is still at 0,0. As if the origin of the coordinate system stays at the original place before the resize in the object model, but somehow the UI knows how to translate it to the new location.

Are we missing any coordinate system transformations that are not needed before CS6 but are needed now?

Thanks a lot.

-Jeff

This topic has been closed for replies.

1 reply

Inspiring
February 27, 2014

Hello Jeff,

InDesign has many coordinate systems, e.g. pasteboard coordinates, spread coordinates, page coordinates, etc. And each page item has its own coordinates. All of them can have differnt origins. In the UI you see the coordinates of the ruler. The origin of the ruler can be changed in Units & Increments of the preferences dialog.

If you create a new document the inner coordinates of a page has its orgin at (0,0). If you change the page size the inner coordinates of the page are changed to keep the transformation matrix to its parent which is the spread.

If you want to have the coordinates from a page item in a coordinate system with the origin at the left top corner of the page you can transform its inner coordinates to the spread coordinates and from the spread coordinates to page coordinates and translate it by the origin of the page.

Hope that helps.

Markus

jzhang82Author
Participant
February 27, 2014

Thanks a lot for the information, Markus.

Sorry that I left some details out of the original post by mistake. The "pageHierarchy" from the code was a pointer pointing at a page itself and not a page item. So the GetBoundingBox is then get supposed to get the page bounds in its inner coordinates (which is the page coordinates). This code was deployed for CS3, and has been returning page bounds properly (i.e. left and top is always 0 and 0 after the pages are resized), and only shows this problem now for CS6.

With some more research done yesterday, I think I might know what is going on here. With the new "variable page size" features exposed with CS6, it seems that now in addition to the concept of "page size" there is now a concept of "page frame". (found from the scripting API guide of CS6). I didn't have time yet to gain a deep understanding of their relationships, but according to the documentation, the page frame defines the geometric bounds of a page, which could now be different than the page size. i.e. if you "resize" a page but not also "reframe" it, the page bounds may have left and top sitting at a non zero value, in the page coordinate system.

I did some experiments which seem to indicate that changing page size via "Document Setup" only "resizes" pages but does not "reframe them". Where if you change page size via the "Page Tool", then the page size and frame are kept in sync.

We are sort of unblocked now by switching our code away from "Document Setup" and use page reframe to resize a page. But below is a case study in case anyone wants to try this out.

- Create a new document with "facing pages" unchecked

- Go to "Document Setup" can expand the page size by some amount

- Get the page bounds in a plugin, and the left and top values of the bounds would be negative

- Place an item having left and top at the top left corner of the page

- Get the page items bounds in page coordinates, and the left and top would have negative values.

- Create a new document with "facing pages" unchecked

- Use the page tool to expand the page size by some amount

- Get the page bounds in a plugin, and the left and top values would be 0,0

- Place an item having left and top at the top left corner of the page

- Get the page items bounds in page coordinates, and the left and top would be 0,0

Thanks.

-Jeff