Forum How do I...?

Finding Exact Position+extent of printed element

Anonymous
I need to find the location and extent of an item where it will be printed on the page.

Can I do something like

var aRect = document.findControl(aTagName).location;

where
aRect is a rectange like- x,y extentx, extenty
document - is the Prince document to be printed
aTagName is the name of the document element to find
mikeday
I need to find the location and extent of an item where it will be printed on the page.

Currently there is no way to do this with Prince, unless you manually examine the generated PDF, which is not very easy.

Adding this feature to Prince would also be rather complicated. It would require a mechanism to select the element whose location/extent you wish to know, and some way to get the information back, perhaps by saving it as an auxiliary XML document. (It is also possible that the element in question could be split over multiple pages, in which case it would have several non-contiguous locations and extents).

Why exactly do you need to find the location and extent of an element? There may be another way to achieve what you are trying to do.

(Note that if you wish to position an element on the page you can use absolute or fixed positioning to control precisely where it will appear).