Get dimensions of a transformed shape/object
Hi All,
I am implementing an extension for InDesign CS6 using Ext Builder 2.1. The extension requires to get some page-item properties in active document and write to a file. I have been able to do most of it.
This issue is in getting bounds and coordinates of transformed page-items. I am able to get the correct bounds for simple page-items. For eg a simple page-item is,

Here is the transformed page-item,

Below is the code I am using to calculate the left, top, width and height.
var bounds:Array = pgItem.geometricBounds as Array;
if(bounds)
{
if(pgItem.strokeWeight)
{
var stroke:Number = pgItem.strokeWeight.valueOf();
if(pgItem.strokeAlignment == StrokeAlignment.CENTER_ALIGNMENT)
{
// top
if(bounds[0])
bounds[0] -= stroke/2;
else
bounds[0] += stroke/2;
// left
if(bounds[1])
bounds[1] -= stroke/2;
else
bounds[1] += stroke/2;
bounds[2] += stroke/2;
bounds[3] += stroke/2;
}
else if(pgItem.strokeAlignment == StrokeAlignment.OUTSIDE_ALIGNMENT)
{
if(bounds[0])
bounds[0] -= stroke;
else
bounds[0] += stroke;
if(bounds[1])
bounds[1] -= stroke;
else
bounds[1] += stroke;
bounds[2] += stroke;
bounds[3] += stroke;
}
}
var left:Number = bounds[1];
var top:Number = bounds[0];
var width:Number = bounds[3] - bounds[1];
var height:Number = bounds[2] - bounds[0];
}
Can anyone tell what I am missing? I am sure I need to handle something for the transformed items.
Please guide.
Thanks!