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

Insert sample page doc.pages.add();

Explorer ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

I can't find one thing, inserting a sample page, for Indesign CS6

doc.pages.add();

Can you recommend documentation, example scripts. I found some, but not this.

Thanks

Jirka

 

TOPICS
Scripting

Views

155

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
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 16, 2022 Oct 16, 2022

Ok so you are trying to create new document pages and apply a parent page to it. Try the following code, it will add a page at the end of the document and apply the master A-Test to it

var doc = app.documents[0]
var ms = doc.masterSpreads.itemByName("A-Test") //Change the name of the master as needed
doc.pages.add(LocationOptions.AT_END, null, {appliedMaster:ms})

You can look the details of the add method using the link below

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

...

Likes

Translate

Translate
Advisor ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

@jirik79416729,

 

What do you mean by "Insert sample page"?? are you referring to a Master or Parent page?

 

Regards,

Mike

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
community guidelines
Explorer ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

Hi
I mean a custom created pattern (Pattern-B), where there would be a template/graphic and where text frames would be added by script.

I still can't find if it is possible to enter CMYK/RBG directly - on

line.strokeColor = "Cyan";

it goes Magenta, Black, Yellow.

Thanks

Jirka

 

 

 

jirik79416729_0-1665871621557.png

 

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
community guidelines
Community Expert ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied


@jirik79416729 wrote:

I still can't find if it is possible to enter CMYK/RBG directly - on

line.strokeColor = "Cyan";

it goes Magenta, Black, Yellow.


You should first create a new color and set the properties that you want like the color type the color values etc and then use that color whereever you want to use it. Something like the following

var c = app.documents[0].colors.add({space:ColorSpace.CMYK, colorValue:[0,0,100,0]})
line.strokeColor = c

-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
community guidelines
Explorer ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

Díky moc, jednoduché, něco podobného jsem zkoušel, ale stále to hlásilo chybu a nebyl jsem si jistý zda rto nejde „přímo".

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
community guidelines
Explorer ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

Thanks a lot, simple, I tried something similar but it kept reporting an error and I wasn't sure if it couldn't be done "directly".

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
community guidelines
Community Expert ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

If you want to add a parent/master page then you can use something like the following

var newMp = app.documents[0].masterSpreads.add(1, {baseName:"Test Parent Page"})

Apart from this you can create whatever elements you want to add to your created master page using different methods provided by DOM. Start by browsing the DOM using the following link

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.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
community guidelines
Explorer ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

I've looked at extendscriptAPI, but I'm not really familiar with it yet. I don't see a usage pattern like for example color above. So I'm trying to look for simple examples accordingly, by code snippet :-(, infinite. I meant this in reverse. Apply pattern to page, add page from pattern. You can generate 3 thousand pages and then manually apply the pattern to all pages at once.

 

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
community guidelines
Community Expert ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

Hi @jirik79416729,

You say you got errors. Just this statement will not help you, we need to know more to send suggestions your way on how to solve the issue. Unless we know what exactly was the code, what is the error you get and then what you are trying to do, all we can do is give generic answers as we tried to do

Regarding samples, there are lots of it. You need to look at the right places and also be clear on what you are trying to find. I will list some things thar I would do if I were in your place

  • InDesign is shipped with a lot of scripts written in JS, Applescript and VB that can be accessed via the scripts panel. You can look at the code of these files
  • This forum is a treasure trove of information about scripting. Lots of scripts have been shared here by fellow members. You just need to search for the right terms and more often than not you will get to a post which will at the least provide you with some code/idea to start your script if not for the complete solution. If you are still stuck, as I said post with all the relevant information and you will most likely get responses

Apart from this I suggest you to use proper terms while posting otherwise you would end up confusing the person trying to understand your post. You said about creating master page, then about color, then now you say about "Apply pattern to page, add page from pattern", what do you mean by pattern? So the post is all over the place with multiple questions. A different questions being asked in response to a suggestion made without giving any concrete details on whether you tried the suggestion, what happened if you did? I hope what I said made some sense and you would try once again to state the things you need help with one at a time, preferably in different posts if the issues are not linked

-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
community guidelines
Explorer ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

I don't speak English well, so the wording, the thinking may not be accurate.
Deepl translates it perfectly, I translate it, then back translate it to see if it's "mangled" and makes sense.
I've looked at other scripts in InDesign. Regarding the line in "CropMarks.jsx" for example, I didn't read it.
The advice from you, was cool ;-).
So I apologize for the inaccuracies.

The above

doc.pages.add();

was meant to create a page from a template, the other way around than it was understood.
Then it is possible to create all pages and transfer the "pattern" to all at once.
Manually I can do it, scripting can't either.

Thank you for your patience and answers

Jirka

jirik79416729_0-1665918820505.png

 

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
community guidelines
Community Expert ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

Ok so you are trying to create new document pages and apply a parent page to it. Try the following code, it will add a page at the end of the document and apply the master A-Test to it

var doc = app.documents[0]
var ms = doc.masterSpreads.itemByName("A-Test") //Change the name of the master as needed
doc.pages.add(LocationOptions.AT_END, null, {appliedMaster:ms})

You can look the details of the add method using the link below

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

-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
community guidelines
Explorer ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

LATEST

That's what I was looking for.

I was also at the above link, but it didn't "click" for me. I tried this procedure too, but it didn't finish. It seemed to me better to copy the "template" with graphics and lines than to generate the lines individually on each page, of which there will be hundreds.

Thanks again

Jirka

   

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
community guidelines