Hi,
I want to position a text type layer 20 pixels distance from the right-most pixel to the right edge of the canvas. What would be the best way to do this? trim/resizeCanvas?
Best regards,
Position a text type layer
Position a text type layer
The text layer must be the active layer..
Code: Select allvar LB= app.activeDocument.activeLayer.bounds;
var Width = app.activeDocument.width.as('px');
var X = (Width - 20) - LB[2].as('px');
app.activeDocument.activeLayer.translate(new UnitValue( X, 'px' ),0);
Code: Select allvar LB= app.activeDocument.activeLayer.bounds;
var Width = app.activeDocument.width.as('px');
var X = (Width - 20) - LB[2].as('px');
app.activeDocument.activeLayer.translate(new UnitValue( X, 'px' ),0);
Position a text type layer
In this case, the bounds property actually corresponds to the last pixel of the text or the edge of the type bounding box? Because normally the type bounding box slightly larger than the text itself. If it corresponds to the edge of the type bounding box, I will need to rasterize the text type layer first.
Position a text type layer
Layer bounds will tell you where the pixels are when rendered. For text it is where the text is located. For a pixel layer it is where the pixels are adjusted for any layer mask.
app.activeDocument.activeLayer.textItem.width and app.activeDocument.activeLayer.textItem.hieght will tell you the size of the text bounding box but only if the text type is paragraph.
app.activeDocument.activeLayer.textItem.width and app.activeDocument.activeLayer.textItem.hieght will tell you the size of the text bounding box but only if the text type is paragraph.