Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Script to apply more than paragraph style on certain range of pages Not all

Engaged ,
Feb 01, 2023 Feb 01, 2023

Hi 

I have an indesign file that contain 3 different designs distrubuted along 100 pages , I have 2 paragraph styles for each design

I want a script to apply certain paragraph styles on text frames of certain pages Not All pages in the File

 

Ex : Paragraph style  (1)  from page 1 to 10 , Paragraph style (2) from page 1 to  10

       Paragraph style (3)  from page 11 to 15 , Paragraph style (4)  from page 11 to 15

 

Can I do that by a script ???

 

       

 

TOPICS
Scripting
4.0K
Translate
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 2 Correct answers

Guide , Feb 01, 2023 Feb 01, 2023
/*
by FRIdNGE, Michel Allio [01/02/2023]
*/

var myDoc = app.activeDocument,
myPages = myDoc.pages;
// "O" is the first page; "4" is the 5st page.
for ( var p = 0; p < 4; p++ ) {
    var myTFrames = myPages[p].textFrames;
    // "myTFrames[1]" is the first text frame created on the page;
    // "myDoc.paragraphStyles.item("1")" is the name ("1") of the para style to be applied;
    // "myTFrames[0]" is the second text frame created on the page;
    // "myDoc.paragraphStyles.item("2")" is the nam
...
Translate
Guide , Feb 01, 2023 Feb 01, 2023

… So if you want "pages 1-4", write this line:

 

for ( var p = 0; p < 4; p++ ) {
 

… if you want "pages 5-9", write this line:

 

for ( var p = 4; p < 9; p++ ) {
 

(^/)

Translate
Engaged ,
Feb 01, 2023 Feb 01, 2023

Any Help Here

Translate
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
Guide ,
Feb 01, 2023 Feb 01, 2023

Hi,

 

Yes, you can do it by Script (with more infos)!

 

(^/)  The Jedi

Translate
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
Engaged ,
Feb 01, 2023 Feb 01, 2023

Thanks for Your Reply

After your permission can you write this script and post it here ?

Translate
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
Guide ,
Feb 01, 2023 Feb 01, 2023

It took me 4 min. to do it with 3 Grep F/R! [100 pages ID file creation, Regex writing + Test]

 

Sure it would take you just 1 second with a Script! (considering the Script time as 0.)

 

(^/)

Translate
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
Engaged ,
Feb 01, 2023 Feb 01, 2023

Sorry , I can't understand 

Can you explain or write full script .jsx that can I put it in scripts folder

Translate
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
Participant ,
Feb 01, 2023 Feb 01, 2023

@FRIdNGEyou say using with GREP style?

Translate
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
Guide ,
Feb 01, 2023 Feb 01, 2023

No, basic F/R supposing there's 1 story!

 

(^/)

Translate
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
Participant ,
Feb 01, 2023 Feb 01, 2023

but... 

ii) Are the texts in different TextFrames or are they a single story?

ii) the texts in different TextFrames not a single story

 

I also thought of next style but @r28071715i111 said "not a single story". 

but it is also possible to create shortcut keys for the styles and nothing that a few manual minutes can't solve the issue. Thinking of just one document.

Translate
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
Participant ,
Feb 01, 2023 Feb 01, 2023

@r28071715i111 

In your example you went from ParagraphStyle(1) to (4). But in the post you mention applying only 2 per page. OK

So your scenario is?
a) the document has 4 different styles;
b) the application takes place in defined ranges;

I would like to think about:
i) How many text boxes are there on each page? Is it a fixed amount throughout the document?
ii) Are the texts in different TextFrames or are they a single story?
iii) The current demand pages are sequential and with a defined "step", like 5 by 5, 10 by 10 pages...
iv) it is certain that there is only one paragraph that uses the same style. I mean can it happen that two paragraphs on the page use the same style?

Can you post a screenshot of your layout or share some kind of preview of your context?

Translate
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
Engaged ,
Feb 01, 2023 Feb 01, 2023

Thanks For Reply ... that is in the document

a) the document has 6 different styles  ... 2 styles for each design of the 3 designs

b) the application takes place in defined ranges ( True ) ... I want styles for certain pages from page .... to page ....

i) There are only 2 text frames in each page throughout the document

ii) the texts in different TextFrames not a single story

iii) The current demand pages are sequential  like 1 by 1 ( Ex : From page 1 to 5 )

I mean only pages 1 , 2 , 3 , 4 , 5 Not other pages

iv) Noooooooo , I want for example the first paragraph style apply only on one text frame Not one the two frames

 

Translate
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
Engaged ,
Feb 01, 2023 Feb 01, 2023

there are a screenshot of the 3 designs and the paragraph styles that i want to apply it on each design

From Page 1 to 8 ... Use Name 1 and Class 1 styles

From Page 9 to 49... Use Name 2 and Class 2 styles

From Page 50 to 100 ... Use Name 3 and Class 3 styles

Translate
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
Participant ,
Feb 01, 2023 Feb 01, 2023

Very nice of you to share your context. There's a lot involved in this layout. It is possible to make a script but maybe the work is not worth it, unless you have thousands of these to do.

 

I would think of variable data (Window >> Utilities >> Data Merge), DataMerge,  to apply these names there. With a little organization of the CSV base and the indesign template, you can solve this much easier than creating/generating a script just for this.

 

At least that's one of the ways I would go:
1) prepare the CSV file with the data (separating into files according to the pair of styles to be applied);
2) prepare the art/matrix in indesign (one for each pair of styles to be applied);
3) would rotate the variable data;

Translate
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
Engaged ,
Feb 01, 2023 Feb 01, 2023

This indesign file already I created using data merge by using csv file and first design and I replaced this design graphic frames with the two other designs ( in links Panel ) along the whole pages

I want to Script instead of creating data merge 3 times seperately .. one time for each design and then merge the 3 indesign files in one document

Are you understand me ?

 

 

Translate
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
Guide ,
Feb 01, 2023 Feb 01, 2023
/*
by FRIdNGE, Michel Allio [01/02/2023]
*/

var myDoc = app.activeDocument,
myPages = myDoc.pages;
// "O" is the first page; "4" is the 5st page.
for ( var p = 0; p < 4; p++ ) {
    var myTFrames = myPages[p].textFrames;
    // "myTFrames[1]" is the first text frame created on the page;
    // "myDoc.paragraphStyles.item("1")" is the name ("1") of the para style to be applied;
    // "myTFrames[0]" is the second text frame created on the page;
    // "myDoc.paragraphStyles.item("2")" is the name ("2") of the para style to be applied;
    myTFrames[1].paragraphs[0].appliedParagraphStyle = myDoc.paragraphStyles.item("1");
    myTFrames[0].paragraphs[0].appliedParagraphStyle = myDoc.paragraphStyles.item("2");
}
alert( "Done!…" )
Translate
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
Guide ,
Feb 01, 2023 Feb 01, 2023

… So if you want "pages 1-4", write this line:

 

for ( var p = 0; p < 4; p++ ) {
 

… if you want "pages 5-9", write this line:

 

for ( var p = 4; p < 9; p++ ) {
 

(^/)

Translate
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
Engaged ,
Feb 01, 2023 Feb 01, 2023

Very Big Great Thanks For You

I tried it and worked as charm

Thank you very very much

 

Translate
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
New Here ,
Mar 17, 2023 Mar 17, 2023
LATEST

Hi FRIdNGE!

I have a very similar question. I have a book of 4 signatures, with text spanning the entirety of the book. I want to use a different paragraph style for each signature, but the text should remain continuous. What would a script look like that basically says:

  • For text frames 1-16, use Paragraph Style 1
  • For text frames 17-32, use Paragraph Style 2
  • For text frames 33-48, use Paragraph Style 3
  • For text frames 49-64, use Paragraph Style 4
Translate
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