Copy link to clipboard
Copied
Hello, I'm creating a ScriptUI dialog which retrieves text from a webserver.
When the user clicks the "OK" button, I'd like to get this text loaded into a placeGun, or something like that.
I mean, the user most choose the page position, by the mouse cursor, to place the retrieved text.
It should behave the same way or similar to "File/Place" tool.
Can someone point me a direction?
There is a similar working proof of concept made by Laubender​ here. But it's not what I want.
Atualizado
My main ideia, on my tests were to check if this was possible:
var txtFrame = app.selection[0];
app.activeDocument.placeGuns.load(txtFrame);
Hi,
You could just create a file and then use that file for the placeGun.
Something like
...// I have it hard coded, but this is the text you get from your webserver
var myText = "Some Text from somewhere else";
// create a new file
var myFile = new File ( Folder.desktop + "/myFile.txt")
// check it doesn't exist
if (! myFile.exists)
{
// open for writing
myFile.open ( 'w');
// write the text from webserver
myFile.write ( myText);
//close
myFile.close();
// place the newly created
Copy link to clipboard
Copied
Hi,
loadPlaceGun() accept only file or files array.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PlaceGun.html#d1e30402__d1e30890
var myFile = File('/Users/username/Pictures/18212468800800.jpg')
app.activeDocument.placeGuns.loadPlaceGun(myFile);
Regards
Copy link to clipboard
Copied
Hi,
You could just create a file and then use that file for the placeGun.
Something like
// I have it hard coded, but this is the text you get from your webserver
var myText = "Some Text from somewhere else";
// create a new file
var myFile = new File ( Folder.desktop + "/myFile.txt")
// check it doesn't exist
if (! myFile.exists)
{
// open for writing
myFile.open ( 'w');
// write the text from webserver
myFile.write ( myText);
//close
myFile.close();
// place the newly created file
app.activeDocument.placeGuns.loadPlaceGun(myFile);
// delete the file
myFile.remove();
}
Hope this helps
Malcolm
Copy link to clipboard
Copied
Hi Malcom,
or you could use an idms file exported from of a formatted text frame you are preparing with InDesign.
I think, that will be the solution our OP is thinking of.
Regards,
Uwe
Copy link to clipboard
Copied
Thank you. I will write the code considering the idms, since I can pre-format the textFrame. Today or tomorrow I'll post my code here, just in case someone needs to reach the same goal!
Thank you all! I was hopping for a more "native" way, instead of exporting a idms or writting an external file. But that will do it!
Copy link to clipboard
Copied
Hi Arthur,
if you are on InDesign CC 2018 look into this here:
Selection export without groupping
Regards,
Uwe