I have to frequently make a hundred or so PDF overlays for video. I used a template with data merge to make a multi-page PDF file of all the overlays. I then run a jscript that saves each page individually and does a search for a specific string from which to name the individual PDF files. I had lot's of help from members of this forum to write this particular script, BTW.
Here is the script:
var destinationFolder = Folder.selectDialog ("Choose a Folder");
var myPDFExportPreset = app.pdfExportPresets.item("TVoverlay");
doc = app.activeDocument;
doc.sections.everyItem().includeSectionPrefix = false;
app.findTextPreferences = null;
app.findTextPreferences.findWhat = 'AutoOffers_^9^9^9^9';
found = doc.findText();
for (i = 0; i < found.length; i++ ){
f = File (destinationFolder + "/" + found[i].contents + '.pdf');
app.pdfExportPreferences.pageRange = found[i].parentTextFrames[0].parent.name;
doc.exportFile (ExportFormat.pdfType, f, false, myPDFExportPreset);
}
The bolded lines are the ones I have a question about. These lines find something that starts with "AutoOffers_" and replace the next four characters with whatever comes next in the text box on that particular page. Every time the naming format changes I have to edit the script. The file name is always in the same text box with the same data merge field name "jobnum". Please see the screenshot below:
What you see in the screenshot is the data merge panel with three of the generated pages. The "jobnum" data field is a non-printing element just off the page in the slug area.
Is there a way I can target this specific (jobnum) field or text container to extract the file name for the generated PDF file? Isthis what the "Script Label" panel is for? If so, would that work?
Thank you all,
Randy