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

GREP code for increasing font size linked to page number?

New Here ,
Mar 07, 2017 Mar 07, 2017

Copy link to clipboard

Copied

Hi,

I'm creating a weird book full of numbers that I want to increase incrementally in size and leading as the page number gets higher. Is there a way of doing that with GREP? I've searched around but can't seem to find anything. There could be 400+ pages so I don't want to do it manually. Please don't ask why I'm creating the book, it's for an art client. End of story.

If I could adjust the text size and leading very slightly on each page that would be magic. I'm a bit of a GREP novice so please excuse me for not being able to figure this out myself.

Thanks

TOPICS
Scripting

Views

749

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
Guide ,
Mar 07, 2017 Mar 07, 2017

Copy link to clipboard

Copied

useful link.. if you know scripting change the script to you needs.. else please ping here

Find and Replace Fonts In All Book Documents?

Votes

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
New Here ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Thanks for your reply. I'm not overly familiar with scripting. I can probably figure out how to import the script in your link to InDesign, but editing to suit my needs is a step too far for me, I suspect. I'm not a complete dunce though, so if you can give me a couple pointers on what I need to do, hopefully I can figure it out!

Votes

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
Guide ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Okay.. see the script below..

I am changing 7/8 size to 9/11.. so try to change the values as desired..

if(app.books.length==0) 

    alert("please open the book") 

    exit(0); 

    } 

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT; 

 

var myBook = app.activeBook; 

var myBookContents = app.activeBook.bookContents; 

 

for(k=0; k<myBookContents.length; k++) 

    var myTotalContents = myBookContents.fullName.toString() 

    app.open(File(myTotalContents)) 

     

    try{ 

    changeFont("7", "8", "9", "11") 

    } 

    catch(e){} 

     } 

 

function changeFont(currFont, currFontStyle, ChangeFont, ChangeFontStyle) 

  app.findTextPreferences = app.changeTextPreferences = null; 

    app.findTextPreferences.pointSize = currFont; 

    app.findTextPreferences.leading = currFontStyle; 

    app.changeTextPreferences.pointSize = ChangeFont; 

    app.changeTextPreferences.leading = ChangeFontStyle; 

    app.activeDocument.changeText(); 

   app.findTextPreferences = app.changeTextPreferences = null; 

    } 

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL; 

HTH

K

Votes

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
New Here ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

OK thanks. Is there a way to bring in the page number as a variable? Say, with each page the point size increases 0.1pt?

Votes

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
Guide ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Votes

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
New Here ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Thanks for your help, I'll have a read about some script basics and see if I can adjust it to my needs.

Votes

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
Guide ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

If you not figure it out... I am changing the current page number into 15..

app.findTextPreferences = app.changeTextPreferences = null;   

app.findTextPreferences.findWhat = "^#";   

app.changeTextPreferences.pointSize = "15";   

app.activeDocument.changeText();   

app.findTextPreferences = app.changeTextPreferences = null;  

Happy learning,

K

Votes

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
New Here ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Thanks so much for your help.

I am struggling to understand this as I can't read the script. For instance:

  • I'm not working with a book file, just a normal ID document file, so does the 'book' mentions in the first line make a difference?
  • Where it says 'changeFont("7", "8", "9", "11")' How does the script know to change 7 and 8 to 9 and 11? Is that taken care of somewhere else in the script?

As you can see, I need to go right back to basic JS and learn that before I can even start to understand what each line is doing. I don't really have the time as the book I'm making needs to be finished by Friday. So I think this time I'm going to cut the page number to 200 and I'll do it the 'dumb' way and maybe next week I'll start to learn basic scripting so that in future I can create scripts myself. Or I get the client to pay for someone to make the script and we can have as many page numbers as they want!

Thanks for your help though!

Votes

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
Guide ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

LATEST
  • I'm not working with a book file, just a normal ID document file, so does the 'book' mentions in the first line make a difference? Yes this is for book, if you want to do this script for a single document use app.documents[0]
  • Where it says 'changeFont("7", "8", "9", "11")' How does the script know to change 7 and 8 to 9 and 11? Is that taken care of somewhere else in the script? This is called the function parameters, it will send the values to the below function 

Votes

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