Please correct me if I'm wrong, but it seems that the only way to export the pages resulting from a data merge as individual PDF files is to do it programmatically. I've searched the forum and I've turned up the following code:
for (i=0; i<app.activeDocument.pages.length; i++)
var myID = app.activeDocument.pages[i].textFrames.item("id").contents;
var myPath = "/d/pdf_output/";
var myFilename = new File(myPath + myID + ".pdf");
I can understand the code snippet well enough but I don't know how to package and invoke it. Would someone be able to help me figure that out under Mac OS X?
1 person found this helpful
More information on this: http://indesignsecrets.com/how-to-install-scripts-in-indesign.php
1 person found this helpful
By the way, nowhere in that script is a page range mentioned. As I understand it, it will export the entire document, once for each page in that document -- for a 30 pg document, you will end up with 30 documents, each 30 pages long.
Use Google; how to export documents to single-page PDFs has come up before.
Thanks. Stepping through the process of learning how to use the ExtendScript Toolkit... and thanks for the tip about defining a page range. So far I've found this line of code...
app.pdfExportPreferences.pageRange = ...
and I'm assuming my value is 1 but I'm not sure it works that way. Maybe I have to increment something for each save so I get one PDF per page of the source ID document. Checking...
Thanks again for your help Jongware in pointing me in the right direction. Together with that post, I've adapted the script to save the single PDFs in a folder of my choosing.
I need to change how the filename is constructed for each page in the (source) data merged document... and I'd like to reference a text frame or two to do that. But I got an error when I added 'myID' to the file name. Is the problem that the text frame variable name <<id>> is no longer available in the merged document?? How can I reference that field?
Here's the code I adapted from Shonky...
This post seems to imply that I'd have to manually go page by page through the resultant data merged document and "tag the boxes with the ID element by using its label property." That seems like a particularly onerous solution, especially if I have a lot of pages.
Is there a way to reference the textframe (text frame) that was <<id>> before I executed the data merge??
I don't know squat about Data Merge -- does this use a single template file? If so, you would tag the (one and only, presumably) text frame in that with "id".
Call up the Script Label panel, click on your text frame to select it, and enter the id "id" into the Script Label text box. Don't press Return, 'cause that will get added to the script label as well ... instead, use Tab to 'leave' the Script Label Text Box.
Note that this does not work with CS5 -- the entire label system was reviewed and changed. If you are on CS5 I'd happily refer you back to the numerous previous discussions on that ...
Roger that re. Data Merge. Yes, there is a single template .indd file that I use Data Merge on. However, the resultant merged file has numerous text frames... so I'll guess I'll have to iterate (like in this post) over the text frames until I find the one labeled 'id'.
Thanks for the tips re. using the Script Label panel. And, no, I'm in CS4. I'll definitely take a look at the CS5 caveats bc we may upgrade at some point.
I wonder if I were to label that text frame prior to Data Merge if the label would be present on each of the resultant data merged pages... ? Hmm...
The answer is YES. If I label the text frame as 'id' in the Script Label panel the data merged file reflects that on each page! Thank goodness!!