Copy link to clipboard
Copied
Hi,
I'm a beginner of javascript. Can anyone know, how to do create a text frame into a used layer?
Please help me with this.
Regards,
KPS
Copy link to clipboard
Copied
Hi,
When we add the textframe, it will be added in active layer only. If you want to change the layer of the item, you should assign the layer to the item.
var actLayer = app.activeDocument.activeLayer; // To get the active layer of the document (ie., here default layer is Layer 3)
alert(actLayer.name)
var tf = app.activeDocument.textFrames.add() // Add textframe.
tf.contents = "TEST"
tf.fit(FitOptions.FRAME_TO_CONTENT);
var lyr1 = app.activeDocument.layers.item("Layer 1"); // To change of the item layer (ie., Changed the layer of the tf from Layer 3 to Layer 1)
tf.itemLayer = lyr1;
Hope this will be helpful.
Copy link to clipboard
Copied
> it will be added in active layer only
No: you can add a frame straight on to a layer. With a reference myPage to a given page, to place a text frame on a layer 'Pictures', do this:
myPage.textFrames.add (app.documents[0].layers.item('Pictures'));
P.
Copy link to clipboard
Copied
Hi,
Thanks for providing the details more clearly.
Could you please anyone know, is there a possibility to send an email from Indesign to Outlook.
I've tried the below script details. But, it doesn't work properly.
var w = new Window ("dialog", "Checklist");
w.orientation = "column";
w.alignChildren = "left";
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
w.add ("checkbox", undefined, "\u00A0Prefer mixed fksldkflsdkfld miexed");
var b1 = w.add ("button", undefined, "OK", {name: "ok"});
var b2 = w.add ("button", undefined, "Cancel", {name: "cancel"});
b1.onClick = function sendEmail ( _name, _email, _subject, _message)
{
mandrill('/messages/send',
{
message:
{
to: [{email: _email , name: _name}],
from_email: 'noreply@yourdomain.com',
subject: _subject,
text: _message
}
},
function(error, response)
{
if (error) console.log(error);
else console.log(response);
});
}
// define your own email api which points to your server.
//app.outlook( '/https://outlook.office.com/api/sendemail/', function(req, res){
//var _name = req.body.name;
//var _email = req.body.email;
//var _subject = req.body.subject;
//var _messsage = req.body.message;
//implement your spam protection or checks.
//sendEmail ( _name, _email, _subject, _message );
//});
w.show ();
Regards,
KPS.
Copy link to clipboard
Copied
Hello KPS,
I suppose that the original question that you posted about layers has been answered. Please take out sometime to review the suggestions posted by people and post back if your issue has been resolved or not, and if it has then mark the question as answered and close this discussion.
Regarding your second query for emails, i don't see this related to the original question. I would suggest you to post a new question for this. It simply does not make sense to post something totally unrelated to the original question midway. I hope you do understand my point and try to make use of this forum in the best possible way both for yourself as well as others.
-Manan
Copy link to clipboard
Copied
Hi,
Sorry for the inconvenience. Going forward, I will be posting a new message.
Regards,
KPS
Copy link to clipboard
Copied
Hi KPS,
look closely into this code snippet:
var doc = app.documents[0];
var myPage = doc.pages[0];
var myLayer = doc.layers.itemByName( "Pictures" );
// One property defined with using add():
myPage.textFrames.add( myLayer );
// More properties defined with using add():
myPage.textFrames.add
(
{
itemLayer : myLayer ,
geometricBounds : [ "10 mm" , "10 mm" , "50 mm" , "50 mm" ] ,
contents : "New Text Frame 2"
}
);
// Even properties that will not come along directly with a text frame:
myPage.textFrames.add
(
{
itemLayer : myLayer ,
geometricBounds : [ "10 mm" , "60 mm" , "50 mm" , "100 mm" ] ,
contents : "New Text Frame 3" ,
parentStory : { pointSize : 20 }
}
);
See into Gregor Fellenz' compilation:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
The DOM documentation sometimes often is very sparse with descriptions of methods, properties or possible values.
That's not Gregor's fault because the documentation above is based on Adobe files. Details here:
Regards,
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now