Merge TextFrames Extension for Adobe InDesign

Justin | ExtendScript, InDesign, extensions | Friday, November 28th, 2008

By request—following similar extensions for Flash and Illustrator—here’s an extension for InDesign that merges multiple textframes into one, while retaining the original styles. Because of properties within InDesign, this extension is actually the most powerful of the three. It accepts characters in the separator field for hard returns, soft returns, and tabs (as well as any combination of any other standard characters). There are also options in the dialog box that control the size of the textframe once it’s been merged (see the variations in the graphic down the page).

I used David Van Brink’s Omino Dialog Maker code again for the dialog box in this extension.

download and instructions below the fold…

Download

Installation

JSX or JS file:

  1. Place the MergeTextframes_ID.jsx into the Scripts Panel directory within your InDesign application directory:

Script Panel directory:
CS3/CS4 > {application directory**}/Scripts/Scripts Panel
CS/CS2 > {application directory**}/Presets/Scripts/Scripts Panel

**Application Directories:
Windows > C:\Program Files\Adobe\Adobe InDesign {version}\
Mac OS X > Applications/Adobe InDesign {version}/

MXP file (CS4 only):

  1. Double-click on the MXP file to install using Adobe Extension Manager CS4.

Usage

Select the textframes you want to merge in InDesign.

Open the scripts panel, Windows > Automation > Scripts.

Locate the MergeTextframes_ID.jsx script in the Scripts Panel and double-click to run the script. If you installed the script using the MXP file, the script with be in the Ajar Productions subfolder. If you’re running InDesign CS3 or CS4 you will be prompted with a dialog box. The dialog box will allow you to select the orientation of the sorting (top, left, bottom, right), use a custom separator character(s), and select options to fit the merged textframe once complete.

Note: This file has not been tested on CS or CS2, as neither of the two were working on my machine for some reason. In CS/CS2, you will not be prompted with a dialog; the script will run using the default settings sorting topmost, then leftmost, with a separator of “[><]“ and no fitting options selected. You can then run a Find and Replace and replace the separator with the characters of your choice. This script will likely run in CS(1), but you may have to change the file extension from .jsx to .js.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Fark
  • StumbleUpon
  • Facebook
  • Google
  • Furl
  • LinkedIn
  • Reddit
  • Technorati
  • TwitThis

12 Comments »

  1. [...] El enlace para descargártelo es el siguiente: http://ajarproductions.com/blog/2008/11/28/merge-textframes-extension-for-adobe-indesign/ [...]

    Pingback by Desfaziendo Entuertos » Blog Archive » Merge TextFrames - Script para mezclar varias cajas de texto en Indesign — November 28, 2008 @ 7:53 am

  2. Justin,

    Firstly, this is awesome for combining headlines, decks, and stories instead of grouping them.

    Secondly, It won’t merge columns. It deletes the multiple columns and makes it one column when it merges. Almost like it doesn’t register mulitiple columns…any suggestions?

    Comment by David — November 28, 2008 @ 8:21 am

  3. Hi David, Thanks for you comment.

    There are different levels on which styling can be applied: character level, paragraph level, object level, etc. Multiple columns is not a property of the text itself, but a property the textframe that houses it. Since, in most cases, we’re moving the text into a different frame, object level styling, like columns, will be lost. There isn’t a great way to retain this, since each frame can potentially have different settings.

    The primary textframe will retain its object-level properties–minus the frame size if you choose to change that in the dialog box–so if you want multiple columns, make sure this frame has multiple columns. For example, if you’re sorting from the left and you want 3 columns, make sure your leftmost textframe has 3 columns. The end result will have 3 columns as well.

    Comment by Justin — November 28, 2008 @ 4:56 pm

  4. Thanks *so* much for creating this! I found out about it at http://www.InDesignSecrets.com, and it’s exactly what I’d been looking for about 2 months ago. Can I send a donation as a sign of gratitude/support?

    Comment by Thatcher — November 30, 2008 @ 3:42 pm

  5. Hi Thatcher, thanks for the feedback. Glad to hear it. I’ll try to add a donation system to the site within the week. Please check back in a few days.

    Donate button is now available at the bottom of sidebar on the right. >>>

    Comment by Justin — December 1, 2008 @ 5:13 pm

  6. [...] für die Fälle, wo der Text in vielen Schnipseln auf einzelne Textrahmen verteilt ist. Die Merge TextFrames Extension for Adobe InDesign, in Wirklichkeit ein Javaskript, macht aus mehreren ausgewählten Textrahmen einen. (via Tips [...]

    Pingback by absatzsetzer.de | Mehrere Textrahmen zusammenfassen — December 2, 2008 @ 7:52 pm

  7. This is an awesome script! The only quarrel I’ve had so far is that you can’t merge two items, undo the merge, and then remerge them with new settings (or at all!). Is there some sort of cache I should be emptying?

    This is the message InDesign displays:

    Javascript Error!

    Error Number: 30614
    Error String: Invalid object for this request.
    Line: 503
    Source: arr[i].previousTextFrame = arr[i-1];

    It really is a great script though! Very useful when you’re creating tags for an XML export, and the designers (for style) use two separate text frames for one chunk of a content-type (i.e. one headline using two textboxes).

    Would you happen to have any tips for maintaining location geometry (position) when combining text frames? For instance, taking your example above, is it possible to maintain the staircase-like positioning of the three text frames? I can somehow imagine this being possible using the properties of tabs and the document’s geometry maybe..

    Thanks again for the wonderful tool!

    Comment by Fahim Moussi — December 3, 2008 @ 8:38 pm

  8. Hi Fahim,
    Thanks for your comments.
    You can undo the script; it just takes more than one undo. To get back to the original state, I believe it takes twice as many undoes as the number of textframes that you merged. The reason it’s double the amount is to undo the addition of each separator. So, for three merged textframes, six undoes will get you back to the state before the script was run.

    I was able to replicate that error by trying to run the script after one undo. I’ll post an updated script at some point so that the error doesn’t appear, but that error only occurs because the undo is incomplete and the two selected textframes are already linked.

    In terms of maintaining the geometry, this is a fairly complex thing to do. It could be simulated somewhat by having the script add returns and tabs, but the positioning of these will vary with the text size, leading, paragraph spacing, indents, and tabs stops contained within each block of text. So this is very difficult to do with any kind of fidelity, and to try and write it to work in every possible scenario. This can be simulated somewhat using the custom separator. The separator field can actually be fairly complex. It could be several returns (\r\r\r\r\r) or a combination of returns and tabs(\r\r\t). In some scenarios, you may also want to run the script in blocks, with a tab(s) between two frames and then a return(s) between that merged frame and another frame or frames on the page. That way you have more control over the relative positioning.

    Comment by Justin — December 4, 2008 @ 3:59 am

  9. [...] the merge text extensions for Flash, Illustrator, and InDesign, Keith Gilbert wrote me wondering about getting swatch information from InDesign to Flash via XFL [...]

    Pingback by New Extension: Send Colors from InDesign and Illustrator to Flash | Ajar Productions — December 5, 2008 @ 10:32 pm

  10. Great script - but one request….

    Would it be possible to set default values for all the options. I often find myself doing repetitive “merging actions” and it would be great to set the options once.

    C

    Comment by Chris Gosling — December 8, 2008 @ 9:27 am

  11. Let me amend my previous comment….

    Make it “easier” to set defaults - I found out where to change things in the coding - but now if I want the “original” version I have to change it back.

    It would also be cool to have a “dialog box free” version after you have set your defaults.

    But let me state again - FANTASTIC script - saves lots of time as is.

    Comment by Chris Gosling — December 8, 2008 @ 9:41 am

  12. Chris,
    Here’s a script with all of the customizable variables at the top: MergeTextframes_ID_Custom.jsx.

    You can make a multiple copies of this file, give them different names, and change the variables at the top of the file. That way you’ll have quick access to every iteration of the script you want to run.

    Comment by Justin — December 8, 2008 @ 6:03 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress