Highlighted

how to specify properties of a placed PDF (or linked indd)

Participant ,
Jun 19, 2020

Copy link to clipboard

Copied

Hi, I am hacking together a script to specify a particular page of a linked indesign file (or PDF).

 

 

currentFile.place(filetoPlace, false, myPrefs);

 

This is the line I use to replace the file.... it all works correctly except I have no idea how to set the page number in myPrefs. 

 

the thing I'm trying to change is the withProperties section of this here: http://jongware.mit.edu/idcs6js/pc_Rectangle.html#place

 

I understand I need to create an object with the correct settings, but don't know how to apply the appropriate settings ---- mainly interested in changing the page number but would be good to know the other settings too.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

This is set by the pdfPlacePreferences object, the code you would need to places the second page of the pdf would be as follows

app.pdfPlacePreferences.pageNumber = 2
currentFile.place(filetoPlace, false);

For other properties on the object see the following 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PDFPlacePreference.html

 

-Manan

TOPICS
Scripting

Views

111

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

how to specify properties of a placed PDF (or linked indd)

Participant ,
Jun 19, 2020

Copy link to clipboard

Copied

Hi, I am hacking together a script to specify a particular page of a linked indesign file (or PDF).

 

 

currentFile.place(filetoPlace, false, myPrefs);

 

This is the line I use to replace the file.... it all works correctly except I have no idea how to set the page number in myPrefs. 

 

the thing I'm trying to change is the withProperties section of this here: http://jongware.mit.edu/idcs6js/pc_Rectangle.html#place

 

I understand I need to create an object with the correct settings, but don't know how to apply the appropriate settings ---- mainly interested in changing the page number but would be good to know the other settings too.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

This is set by the pdfPlacePreferences object, the code you would need to places the second page of the pdf would be as follows

app.pdfPlacePreferences.pageNumber = 2
currentFile.place(filetoPlace, false);

For other properties on the object see the following 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PDFPlacePreference.html

 

-Manan

TOPICS
Scripting

Views

112

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
Jun 19, 2020 0
Adobe Community Professional ,
Jun 19, 2020

Copy link to clipboard

Copied

This is set by the pdfPlacePreferences object, the code you would need to places the second page of the pdf would be as follows

app.pdfPlacePreferences.pageNumber = 2
currentFile.place(filetoPlace, false);

For other properties on the object see the following 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PDFPlacePreference.html

 

-Manan

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...
Jun 19, 2020 2
Participant ,
Jun 21, 2020

Copy link to clipboard

Copied

Many thanks Manan, that's what I needed!

now I have another small problem where I am trying to set the page number with 

var chosenPage = prompt("Choose Page Number:", "2");

then chosenPage returns my typed in number.
however, if I then try to put it in placePreferences like this 

app.pdfPlacePreferences.pageNumber = chosenPage;
app.importedPageAttributes.pageNumber = chosenPage;

 then extendscript returns an error like this 'Invalid value for set property 'pageNumber'. Expected Long integer, but received "2".

weird because 2 looks the same to me as the 2 we specified after pageNumber earlier, which worked!

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...
Jun 21, 2020 0
Adobe Community Professional ,
Jun 21, 2020

Copy link to clipboard

Copied

The property needs an integer value and you are giving it a string value which happens to be number, hence the error. You need to convert your string to number. Use the following, in place of chosenPage to convert it into integer

parseInt(chosenPage) 

 

-Manan

 

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...
Jun 21, 2020 1
Participant ,
Jun 21, 2020

Copy link to clipboard

Copied

ahah! perfect, many thanks Manan Joshi 🙂

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...
Jun 21, 2020 0