PDF- Filename automated from labelscript (after data merge)
dieselheart_ Oct 8, 2011 4:34 AMHello,
first of all I'm quite new in javascripting... but some simular scripts I have found on the internet could provide a solution for my problem.
What I've done is the following: I've used Data Merge and created a 200-paged file with 1 label on each page. Each label has a labelnumber.
What I could do is export the file - split it up in 200 different pages - rename each file to the specific labelname. Seems a lot of work and this job I need to repeat about once a month.
I looked for a solution and came to these discussion: http://forums.adobe.com/thread/289666http:// http://forums.adobe.com/message/3178412#3178412
What I want to create is a script that I can run every month after I have updated my 200 labels and overrides all the pdf-files of the old labels.
With the different scripts I have found I constructed the code below.
The script works, it prints to multiple pdf's which have the correct labelnames, export is according to the requested presets, but the CONTENT of each label is the content of the FIRST label (first page).
I have tried a lot of thing (trail&error) but as I said, I'm quite new to this matter...
So.... I can use some help or advice on this one.
Thanks in advance,
Dheart
function getLABEL_A(page) {
for (var currentTextFrameIndex=0;currentTextFrameIndex<page.textFrames.length; ++currentTextFrameIndex) { // Iterates over frames
if (page.textFrames[currentTextFrameIndex].label=="LABEL_A") // if label is LABEL_A..
return page.textFrames[currentTextFrameIndex].contents; // ..returns text frame contents
}
return null; // if not found, returns null
}
var LABEL_A;
var pagesList=app.activeDocument.pages;
for (var currentPageIndex=0;currentPageIndex<pagesList.length;++currentPageIndex) { // Iterates over pages list
currentPage=pagesList[currentPageIndex];
LABEL_A=getLABEL_A(currentPage);
if (LABEL_A!=null) { // If we have a LABEL_A - PDF file name-
var export_preset = app.pdfExportPresets.item("[Smallest File Size]");
app.activeDocument.exportFile(ExportFormat.pdfType,"F:/.../"+LABEL_A+".PDF",false,export_ preset); //.. and save the file
} else {
alert("Page number "+currentPageIndex+" NO LABEL_A");
alert(LABEL_A);
}
}

