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...

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!

Bookmark
Please login to bookmark Close

This article was last modified on December 18, 2021

Comments (14)

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Gavin Anderson

    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).

  2. Your site is perfect!

  3. 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!!

  4. 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.

  5. 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?

  6. Oscar Stoneman

    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

  7. Oscar Stoneman

    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

  8. Mike Fontecchio

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

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

  10. Anne-Marie

    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.

  11. 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?

  12. Steve Werner

    Mayra,

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

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

  14. Thanks Peter!! This is great!