Copy link to clipboard
Copied
I know to create textFrame with geometric bounds but I only have width and height as input for textFrame. Is there anyway to create it with only width and height or please suggest the possible way!
Assuming four variables:
y: the frame's vertical position
x: the frame's horizontal position
width and height speak for themselves.
app.documents[0].textFrames.add ({
geometricBounds: [y, x, y+height, x+width];
});/
Hi @Karthik SG , you could also wrap Peter‘s code in a function—here the parameters are x,y, width, height, destination page
var tframe = makeTextFrame(1,1,5,3,app.activeWindow.activePage)
/**
* Makes a new text frame on the active page
* @ param x position
* @ param y position
* @ param width
* @ param height
* @ param target page
* @ return the text frame
*/
function makeTextFrame(x,y,w,h,p){
return p.textFrames.add ({ geometricBounds: [y,x,y+h,x+w]});
}
Copy link to clipboard
Copied
Assuming four variables:
y: the frame's vertical position
x: the frame's horizontal position
width and height speak for themselves.
app.documents[0].textFrames.add ({
geometricBounds: [y, x, y+height, x+width];
});/
Copy link to clipboard
Copied
Thanks Manan!
Copy link to clipboard
Copied
Hi @Karthik SG , you could also wrap Peter‘s code in a function—here the parameters are x,y, width, height, destination page
var tframe = makeTextFrame(1,1,5,3,app.activeWindow.activePage)
/**
* Makes a new text frame on the active page
* @ param x position
* @ param y position
* @ param width
* @ param height
* @ param target page
* @ return the text frame
*/
function makeTextFrame(x,y,w,h,p){
return p.textFrames.add ({ geometricBounds: [y,x,y+h,x+w]});
}
Copy link to clipboard
Copied
Hi @Karthik SG ,
you could add more property : value pairs to the object that is the only argument of method add().
Also note, that the frame is added to the first spread in your document, because no spread or page is specified.
And you could use strings for the measurement values and also mix them.
Sample code:
var propValueObject =
{
geometricBounds :
[
"10 mm" , // y
"10 mm" , // x
"200 pt" , // y + height
"100 pt" // x + width
]
};
app.documents[0].textFrames.add( propValueObject );
Regards,
Uwe Laubender
( Adobe Community Professional )