Indesign data merge export to pdf

Hello All,
I have a bunch of labels that I routinely output to a pdf and then send to the printer.

I’ve scripted the majority of what I would like it to do, and it’s working well:

In Excel:

  1. Add headers
  2. fill in formulas
  3. fill down to the last record
  4. export as tab delimited file

In indesign:
5. Create new file from template
6. save-as with the proper name
7. relink new data

The last thing I’m trying to do it set it to export to a pdf from the data menu flyout. I’ve found that I can export it to a merged indesign document, but I can’t find any code to let me export from the data-tied indesign file to the pdf.

Can you point me in the correct direction?

The following code will merge into a non-data-tied indesign file. Can i substitute a few commands to turn it into a script that exports pdfs? I’d like to be able to suppress warnings.

tell application id "com.adobe.indesign"
	tell data merge properties of document 1
		tell data merge preferences
			set record selection to all records
			set records per page to multiple record
		end tell
		try
			merge records
		end try
	end tell
end tell

In the mean time, I’ve assigned a key command, but it’s more of a work around.

Thanks,
Andrew

Not sure exactly what you’re trying to do with what (or which version of ID you have) but couldn’t you add something like this to your script?

tell active document
    export format PDF type to "folder:test.pdf" without showing options 
end tell

I don’t see anything specific to ‘merge’ in the applescript doc (but I’m looking at CS6 so who knows) but the above should generate a pdf based on whatever the document’s state is.

Thanks Mockman. I have the latest version, but it should be about the same in CS6. This is a data merge using a tab delimited file. I make one avery label template, and indesign makes the rest.

template

info preview

Indesign will step and repeat this for me for a full sheet of 30.

A merged document can take 2 forms.

1.Merge the data into an indesign file. This sort of ‘flattens’ the file so it’s not tied to the data anymore. This is what I have code for, but not what I’d like.

  1. Keep the base template with data tied to it and then export a pdf. This is what I would like to accomplish, but cannot figure out the script. Keeping the data separate from the ID file means the client can updated the tab delimited file.

Andrew

It might be that you can’t skip the merged file stage — at least not using applescript. Couldn’t you duplicate the template, flatten one copy and export that to pdf — and then delete the flattened intermediate stage?

That said, I’m not knowledgeable about the app — I just quickly perused the the CS6 Scripting Guide.

Hi. A data merge is a semi-automated method that simply stores a placeholder to later import into the painted target. It’s unclear if you tried the code in post #2 or what you expect to be exported from the unmerged state—blanks or tags? When you merge records to a data merge reference in earlier versions, a new document should be spawned. Both document 1 and 2 can then be exported to PDF.

I figured it out. Instead of the command merge records, it’s export. Much like a normal pdf export, but in the data merge block.

set PDFPreset to "Medium resolution" as string
	set MyPDFexportPreset to PDF export preset PDFPreset
	
	tell data merge properties of document 1
		tell data merge preferences
			set record selection to all records
			set records per page to multiple record
		end tell
		try
			export to (thePath & theFileName & ".pdf") using MyPDFexportPreset without showing options
		end try
	end tell

This allows the pdf export to happen without the intermediary step of creating a merged InDesign document first.

The export command is listed in the InDesign dictionary, but not under the other merge prefs or options. Even though it has merge in the description, it doesn’t come up in the dictionary search results.

Thanks for all the resources. I wouldn’t have been able to do it without this forum.

Andrew

Glad you found a solution. You should look for the current indesign applescript doc. It’s likely on Adobe’s indesign help pages (under Extend InDesign > Automation > Scripting). I had looked at the CS6 edition (2012). It’s 244 pages and focuses on scripting the app. Plus they appear to have example scripts on the site.