Copy link to clipboard
Copied
Hello. I currently work with quite a few InDesign template files (simply indesign files), which require me to relink pdf files to objects. I currently have a script that will save out the InDesign file to the specific location that needs to be saved to.
My current script looks like this:
var pt = app.paste();
if(app.activeDocument.saved == false) {
app.activeDocument.save(new File("PATH" + pt + ".indd"));
}
Thinking it through, I don't think the pasted text (app.paste) would work for the name, but I'm not sure if there's a way to grab the clipboard text, as I didn't see anything on the InDesign javascript scripting manual regarding this. Is something like this even possible/would there be any work arounds to being able to grab the text from the clipboard?
Thank you!
You need to paste it into something that you can then access. Calling paste on text makes a new textframe on your document and selects it. Thus, you can get it like this. I assume you have "PATH" defined somewhere else; in this case I saved to the Desktop.
var doc = app.activeDocument;
app.selection = null;
app.paste();
var sel = app.selection[0];
var pt = sel.parentStory.contents;
var path = "~/Desktop/";
if(doc.saved == false) {
doc.save(new File(path + pt + ".indd"));
}
sel.remove(
...
Copy link to clipboard
Copied
You need to paste it into something that you can then access. Calling paste on text makes a new textframe on your document and selects it. Thus, you can get it like this. I assume you have "PATH" defined somewhere else; in this case I saved to the Desktop.
var doc = app.activeDocument;
app.selection = null;
app.paste();
var sel = app.selection[0];
var pt = sel.parentStory.contents;
var path = "~/Desktop/";
if(doc.saved == false) {
doc.save(new File(path + pt + ".indd"));
}
sel.remove();
Copy link to clipboard
Copied
This is exactly what I was looking for. Yes, I had a path already established and just had PATH as a substitute.
Thank you so much!