June 25 2006 • 6:06 PM

Free Add-a-Page Script

InDesign expert Peter Kahrel wrote a free script for InDesign users that solves a common annoyance, and is graciously sharing it with other InDesign fans here at InDesignSecrets.com.

Normally, when you’re writing your Great American Novel and come to the end of the last page’s text frame, InDesign just oversets that frame, it doesn’t add a page for you. You have to do that yourself, and then thread the overset frame to a new one on the new page. Only then can you switch back to the Type tool and continue typing.

Peter’s cross-platform Javascript is called Add-a-Page. It’s simple but oh-so-useful: it adds a page at the end of the current document, places a text frame on it, and links the new text frame to the one containing your text cursor.

With the script installed, that means when you’re nearing the end of the last text frame, you could just double-click Peter’s script in the Scripts palette (or use a keyboard shortcut you’ve assigned to it), and keep typing. The cursor jumps to the frame in the next page when it needs to, and your train of thought is uninterrupted.

Thanks, Peter!

14 Responses discussing this post. Add yours below.

  1. June 25th, 2006 • 6:24 pm • Link

    Thanks Peter!! This is great!

  2. mayra
    June 27th, 2006 • 2:37 pm • Link

    when I double clicked on the “kahreladdpage.jsx” the script opened in a different window. Not sure what todo with the script alone.

  3. Steve Werner
    June 27th, 2006 • 2:48 pm • Link

    Mayra,

    It sounds like you didn’t read the “How to install an InDesign script” instructions. It worked fine for me.

  4. Tricia
    July 2nd, 2006 • 10:09 pm • Link

    hey guys… do you know if this script works on indesign cs (mac)? i did the same thing for my indesign cs2 (pc) at work and no drama. any suggestions?

  5. Anne-Marie
    July 2nd, 2006 • 11:01 pm • Link

    Mayra, the script is an uncompressed text file so downloading it does what your browser normally does with uncompressed text files … suppose we should .zip it or something. But if you right-click on it you can choose Download Linked File which should work. Even so, my browser downloaded it with a .txt extension added after the .jsx, so I had to delete the extraneous extension.

    Tricia, all I know is that it definitely works on Mac InDesign CS2, haven’t tested it on Windows CS2 but it should work there too. When you say “no drama” is that good or bad. :-) As far as compatibility w/CS1, there may be something new in the javascript that CS1 doesn’t recognize.

  6. Tricia
    July 3rd, 2006 • 2:58 am • Link

    I see. I guess I’ll probably have to upgrade to CS2 then. Which is probably a good thing. =)

  7. Mike Fontecchio
    July 5th, 2006 • 9:36 pm • Link

    Tricia, try renaming the file .js and see if that works.

  8. Oscar Stoneman
    August 6th, 2006 • 7:19 pm • Link

    Seems that the script ignores margin preferences of even pages of double sided spreads. The left margin alway is the left margin of odd pages.

    Thanks for the Script anyway.
    Oscar

  9. Oscar Stoneman
    August 6th, 2006 • 7:30 pm • Link

    To distinguish between even and odd pages fo double sided spreads you need something like this:

    ===================
    // add a page at the end of the current document,
    // place a text frame on it, and link the text frame

    doc = app.activeDocument
    np = doc.pages.add();
    marg = np.marginPreferences;
    if (np.documentOffset%2) // margin of even or odd page
    {
    theLeftMargin = marg.left;
    theRightMargin = marg.right;
    }
    else
    {
    theLeftMargin = marg.right;
    theRightMargin = marg.left;
    }
    gb = [marg.top, theLeftMargin,
    doc.documentPreferences.pageHeight - marg.bottom,
    doc.documentPreferences.pageWidth - theRightMargin];

    oldRuler = doc.viewPreferences.rulerOrigin
    doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    with( doc.pages[-1].textFrames.add() )
    {
    geometricBounds = gb;
    previousTextFrame = doc.pages[-2].textFrames[0];
    }
    doc.viewPreferences.rulerOrigin = oldRuler
    ===================
    Oscar

  10. September 5th, 2006 • 4:17 am • Link

    When I clicked on the link I got this.

    // add a page at the end of the current document,
    // place a text frame on it, and link the text frame

    doc = app.activeDocument
    np = doc.pages.add();
    marg = np.marginPreferences;
    gb = [marg.top, marg.left,
    doc.documentPreferences.pageHeight - marg.bottom,
    doc.documentPreferences.pageWidth - marg.right];
    oldRuler = doc.viewPreferences.rulerOrigin
    doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    with( doc.pages[-1].textFrames.add() )
    {
    geometricBounds = gb;
    previousTextFrame = doc.pages[-2].textFrames[0];
    }
    doc.viewPreferences.rulerOrigin = oldRuler

    the script opened in a browser window. How do I drag that into a indesign package?

  11. Anne-Marie
    September 5th, 2006 • 4:57 am • Link

    Ralph, it did that because the .jsx file is actually a text file and your browser is set to open those in a browser window. (mine downloads text files.) Try right-clicking on the link and choosing Download Linked File. Or you can copy/paste the content that appears in the browser window into a new plaintext document and save it with a .jsx extension.

  12. Peter Race
    October 10th, 2006 • 4:09 pm • Link

    Using windows version CS1, renaming the .jsx file to a .js file lets the script work perfect. Just wanted to let those of you know who were still unclear. Thank you!!

  13. Peter
    May 13th, 2007 • 8:28 am • Link

    Your site is perfect!

  14. April 7th, 2009 • 11:31 am • Link

    Sweet script! As a Graphic Designer, this one will come in very handy. I’ve added a Keyboard Shortcut for this: Option + Shift + P (on the Mac), since Command + Shift + P is the built in Add Page feature (but does not include the addition of a link text box).

Subscribe to the Discussion

Get the ongoing discussion surrounding "Free Add-a-Page Script" delivered to you. Click here to subscribe via RSS.

Leave a Reply

You can use limited HTML tags, such as <em></em> for emphasis/italics and <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

InDesignSecrets reserves the right to edit and/or remove posts and comments.