Javascript: Placing an Item with multiple artboards

Community Beginner ,
Dec 30, 2020

Copy link to clipboard

Copied

Is there a way to access the import options on a placed item?

 

if you place an ai file with multiple artboards you are allowed to choose which "page" is placed, but when using the javascript it defaults to the first page. Is there a way to access that? I have looked through the javascript guide, but havent found anything.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional
// place a specific Artboard from an ai doc

var idoc = app.activeDocument;

var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = 4; // it works for Artboards since placing an ai file places the pdf version

var iplaced = idoc.placedItems.add();

iplaced.file = File( '/c/...full path.../your file.ai');
TOPICS
Scripting

Views

61

Likes

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

Javascript: Placing an Item with multiple artboards

Community Beginner ,
Dec 30, 2020

Copy link to clipboard

Copied

Is there a way to access the import options on a placed item?

 

if you place an ai file with multiple artboards you are allowed to choose which "page" is placed, but when using the javascript it defaults to the first page. Is there a way to access that? I have looked through the javascript guide, but havent found anything.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional
// place a specific Artboard from an ai doc

var idoc = app.activeDocument;

var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = 4; // it works for Artboards since placing an ai file places the pdf version

var iplaced = idoc.placedItems.add();

iplaced.file = File( '/c/...full path.../your file.ai');
TOPICS
Scripting

Views

62

Likes

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
Dec 30, 2020 0
Engaged ,
Dec 30, 2020

Copy link to clipboard

Copied

My understanding is that artboards are not container objects; i.e. artboards do not contain items (e.g. placedItems). But you can position an item "on" an artboard; you just position the item in relation to the artboard in question.

 

var yourFile = new File(path);
var yourPic = app.activeDocument.placedItems.add();
yourPic.file = yourFile;

var AB = app.activeDocument.artboards[index];
// var AB = app.activeDocument.artboards.getByName(name);
yourPic.position = [AB.artboardRect[0], AB.artboardRect[1]];

 

Edit:  It seems I misunderstood the question. 

Likes

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
Reply
Loading...
Dec 30, 2020 0
Adobe Community Professional ,
Dec 30, 2020

Copy link to clipboard

Copied

// place a specific Artboard from an ai doc

var idoc = app.activeDocument;

var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = 4; // it works for Artboards since placing an ai file places the pdf version

var iplaced = idoc.placedItems.add();

iplaced.file = File( '/c/...full path.../your file.ai');

Likes

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
Reply
Loading...
Dec 30, 2020 1
Resources