Skip to main content
Known Participant
May 5, 2009
Question

[JS IDS CS4] placing Indd-files

  • May 5, 2009
  • 1 reply
  • 2475 views

Hi all,

I'm trying to place an InDesign-file via JavaScript, if the script is run from the client it works like a charm but on the server I get an error.

app.documents.item(0).rectangles.itemByID(ItemID).place("Macintosh HD:Test.indd")[0];

If I point to a PDF works just fine.

Is IDS not capable of placing indd-files?

Error:

JavaScript Error!\n\nError Number: 45\nError String: Object is invalid\n\nFile: /Scripts/PlaceInddFile.jsx\nLine: 34\nSource: app.documents.item(0).rectangles.itemByID(ItemID).place("Macintosh HD:Test.indd")[0];

--

molsted

This topic has been closed for replies.

1 reply

Inspiring
May 5, 2009

Try passing a file object rather than the name of a file.

Do a test to make sure the file object exists before committing to the place.

Dave

Known Participant
May 6, 2009

Hi Dave

Here's the script I'm using:

var FilePath = "Macintosh HD:Test.indd"
var PageNr = 2;


//GET THE PAGEITEM
var MyBox=app.documents.item(0).rectangles.itemByID(ItemID);
               
if (FilePath.exists) {
     
     app.importedPageAttributes.pageNumber = PageNr;
     app.importedPageAttributes.importedPageCrop = 1131573314;
               
     //Place image in graphics frame
     MyBox.place(FilePath)[0];
}

Can you make an example on how pass a file object rather than the name of a file?

The, to me, strange part is if I point FilePath to a PDF it just works, eg.:

var FilePath = "Macintosh HD:Test.pdf"
var PageNr = 2;


//GET THE PAGEITEM
var MyBox=app.documents.item(0).rectangles.itemByID(ItemID);
               
if (FilePath.exists) {
     
     app.importedPageAttributes.pageNumber = PageNr;
     app.importedPageAttributes.importedPageCrop = 1131573314;
               
     //Place image in graphics frame
     MyBox.place(FilePath)[0];
}

--

molsted

Kasyan Servetsky
Legend
May 6, 2009

MyBox = app.selection[0]; // a rectangle is selected
var FilePath = "Macintosh HD:Test.indd";
var myFile = new File(FilePath); // the reference to a file
MyBox.place(myFile);