Thanks for coming to, the world's #1 resource for all things InDesign!

Data Merging Individual Records to Separate PDFs Part 2: via Scripting

In my last post, I outlined how to create individually named PDFs from a Data Merge using:

  • bookmarks from a table of contents; and
  • bookmarks from document structure

I had mentioned that at the time of writing, I had been considering the use of a script to take a specific paragraph or character style to convert to bookmarks, and that Ukrainian scripter Kasyan Servetsky had a script that came close, but only created text anchors that were hidden instead of bookmarks.

Since that post was written, a third method now exists to create individually named PDFs from an InDesign Data Merge that has been merged into one file (or any InDesign document for that matter):

A script to make bookmarks based on a paragraph style

For this technique, you will need the “addbookmarksfromparagraphstyle.jsx” script. Add this script to your Scripts panel (for more information on installing and using scripts, see this post).

Once again, we’ll create a set of business cards and the PDFs will be named exactly as the names on each business card. The first two steps are identical to the previous article.

1. Prepare the base file – the merge fields do not have to be on the master pages. Make sure that the names have a unique paragraph style – in this example the style is called “consultant”.


2. Merge to a new InDesign file, making sure that the overset text warning reports no overset text.


3. Once the new merged InDesign file is created, navigate to the Scripts panel and run the addbookmarksfromparagraphstyle.jsx script.


4. A prompt will ask what paragraph style to choose. Select the desired style from the dropdown menu and click OK.


The script will then run and on completion, a “completed” dialog box will appear. In the bookmarks panel, all of the names will now be assigned bookmarks.


From here, steps 5 and 6 are identical to the previous article:

5. Export the InDesign file to a PDF, with bookmarks turned on.


6. Open the PDF in Adobe Acrobat. Go to the Bookmarks panel and make sure that the bookmarks have been created. If so, go to the Pages tools and select Split Document. In the new dialog box, check the radio button Top-level bookmarks and click the Output Options button. In this dialog box, choose a new folder to save the resulting PDFs (if necessary) and in the File Labeling portion of the dialog box, check the Use Bookmark Names for File Names radio button.



As with the previous methods, this technique will not work if the merge contains records that have the same name.

If you would rather use a character style instead of a paragraph style, there is an alternate version of the script that allows bookmarks to be made from character styles instead.

True thanks and credits should go to:

My contribution was to simply stitch the two scripts together.

One final note: just as I was finishing this article, I saw that Austrian designer and scripter Roland Dreger has released a Beta version of his script that will also make bookmarks from Paragraph and Character styles. Check out his script here.

Colin Flashman

Colin Flashman

A prepress operator and graphic designer for a South Australian commercial printer, with close to 20 years of experience in the trade. He is also a regular contributor to this site and InDesign Magazine, and hosts his own prepress blog "Colecandoo".
Colin Flashman

Latest posts by Colin Flashman (see all)

  • - November 30, -0001
Related Articles

11 Comments on “Data Merging Individual Records to Separate PDFs Part 2: via Scripting

  1. It is worth noting that the various scripts to create bookmarks do not have to be used exclusively for the purpose outlined in the article, and are handy to create bookmarks generally in situations where generating a TOC would not be as appropriate.

    That said, all of the “make bookmark” scripts are now coming out of the woodwork, and there is ANOTHER bookmarking script available, but this will bookmark index entries. Have a look:

  2. Hi,

    After merging, an easiest and less time consuming process is to export pages one by one as PDF using the PageExporterUtility5.0.1.jsx script:
    Or Batch convert-export.jsx, or Custom Export.jsx or (Mac only).

    • These solutions I have offered have a unique point of difference and that is the resulting files generated have a unique name taken from text in the document, rather than just 001, 002, 003 – I agree that is easy and can be done elsewhere.

      Pageexporterutility and customexport will not uniquely name the resulting PDFs as is the case in the demo (the filenames take their names from the words that have the character or paragraph style applied).

      Batch convert needs the resulting merge files to be separate to begin with (e.g. have 100 uniquely named indesign files for the example above).

      Loic Aigon (creator of customexport) did have another script that was an improvement on this but it is no longer available from his site

      I cannot speak for inexport though as I have not used this solution.

  3. I’m having a slight problem with this.

    I can add the bookmarks via the above script in Indesign (CS5.5) and they function as expected; but when I open the pdf in Acrobat Pro(10), all the bookmarks point to the first page in the pdf.

    Any ideas?

    • Answering my own question here…

      I need quite specific file names that couldn’t be shown in the business card content (order number etc.), so set up my bookmark paragraph style in a text box with the non-printing attribute checked. If I uncheck non-printing it works as expected. Oh well.

      • Crikey, seems like I am spamming the board.

        A simple solution is to move the box onto the pasteboard with part of it overhanging the page (the bookmarks don’t appear in acrobat at all if none of the text box is on the page).

        Great site btw. I read it every day.

  4. Thought I would also add that you don’t need a script for this – make a table of contents and enable ‘create pdf bookmarks’. The ToC doesn’t need to be visible on the page – fully on the pasteboard is ok.
    Note that you need to manually run ‘update table of contents’ when pages/paras change.

Leave a Reply

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