Edit a Java Script in InDesign

Community Beginner ,
Jul 24, 2020

Copy link to clipboard

Copied

Hi,

I'm using the java script to place a multi page PDF file. It works as advertised, but I want it to place the pdf file at a certain x axis. I've tried editing the java script that comes with InDesign and it won't let me. 

 

          app.pdfPlacePreferences.pageNumber = myCounter;
          myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
          if(myCounter == 1){

Instead of placing the pdf pages at 0,0 I want to place them at 0, 1.75

 

I've also tried copy the text in the script and putting it into a text edit file and also a Word file and none of them will let me save it.

 

Any suggestions on how to do this?

 

Thank you,
Maria

Correct answer by mariaayala | Community Beginner

Hi Manan,

 

I figured it out. I had to go to the script file, get info and give myself permission to edit it. It was marked as Read Only. I changed it to Read and Write and now I can change where I want the pdf files placed in my InDesign document. I also learned that the code is written for x axis followed by y axis (as it should be).

 

Thank you for your efforts.

Maria

TOPICS
How to, Scripting

Views

72

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

Edit a Java Script in InDesign

Community Beginner ,
Jul 24, 2020

Copy link to clipboard

Copied

Hi,

I'm using the java script to place a multi page PDF file. It works as advertised, but I want it to place the pdf file at a certain x axis. I've tried editing the java script that comes with InDesign and it won't let me. 

 

          app.pdfPlacePreferences.pageNumber = myCounter;
          myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
          if(myCounter == 1){

Instead of placing the pdf pages at 0,0 I want to place them at 0, 1.75

 

I've also tried copy the text in the script and putting it into a text edit file and also a Word file and none of them will let me save it.

 

Any suggestions on how to do this?

 

Thank you,
Maria

Correct answer by mariaayala | Community Beginner

Hi Manan,

 

I figured it out. I had to go to the script file, get info and give myself permission to edit it. It was marked as Read Only. I changed it to Read and Write and now I can change where I want the pdf files placed in my InDesign document. I also learned that the code is written for x axis followed by y axis (as it should be).

 

Thank you for your efforts.

Maria

TOPICS
How to, Scripting

Views

73

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
Jul 24, 2020 0
Adobe Community Professional ,
Jul 24, 2020

Copy link to clipboard

Copied

Hi Maria,

 

Is the issue that you are not able to save and test your edited code or that it does not produce correct results?

 

If it is the edit issue, then i would suggest to create a file using a simple text editor like notepad on Win and Textpad on a MAC. Paste your code into a new file you create in these editors and save it with extension jsx. Then place it in the scripts folders and then you can execute it using the scripts panel within InDesign.

 

I would not disturb you with learning to code by giving any suggestion right now until you ask for help. Happy coding

 

-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...
Jul 24, 2020 0
Community Beginner ,
Jul 24, 2020

Copy link to clipboard

Copied

Hi Manan,

I've been able to save the edited code. I want to place the pdf file at 0 and 1.75.

 

app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
if(myCounter == 1){
var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
 
I edited the code in TextEdit and then saved it with the .jsx extension. I placed it into the Scripts folder and it does appear in the Users Script folder. When I try to run it, it gives me an error. 
Screen Shot 2020-07-24 at 12.48.18 PM.png
I thought that maybe it did not like the decimal point in the number so I changed it to 0,1 and I still got an error.
Screen Shot 2020-07-24 at 12.56.10 PM.png
InDesign gives me the option to edit the existing script, but once I make the change and try to save it, it tells me that I cannot save it.
Thank you,
Maria

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...
Jul 24, 2020 0
Community Beginner ,
Jul 24, 2020

Copy link to clipboard

Copied

Hi Manan,

 

I figured it out. I had to go to the script file, get info and give myself permission to edit it. It was marked as Read Only. I changed it to Read and Write and now I can change where I want the pdf files placed in my InDesign document. I also learned that the code is written for x axis followed by y axis (as it should be).

 

Thank you for your efforts.

Maria

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...
Jul 24, 2020 0
Adobe Community Professional ,
Jul 24, 2020

Copy link to clipboard

Copied

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...
Jul 24, 2020 1