• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to load any PageItem into a placeGun or a contentPlacer?

Community Beginner ,
Aug 08, 2018 Aug 08, 2018

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);

but it doesn't work.
TOPICS
Scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 08, 2018 Aug 08, 2018

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

...

Votes

Translate

Translate
Enthusiast ,
Aug 08, 2018 Aug 08, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2018 Aug 08, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2018 Aug 08, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2018 Aug 08, 2018

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2018 Aug 09, 2018

Copy link to clipboard

Copied

LATEST

Hi Arthur,

if you are on InDesign CC 2018 look into this here:

Selection export without groupping

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines