Skip to main content
Participant
February 16, 2011
해결됨

Data Merge export to single pdf and auto naming

  • February 16, 2011
  • 1 답변
  • 1340 조회

Hi All,

I have a question that I have been searching for the answer on here for a few hours...

I am needing to make up around 200 certificates

Each certificate will have 3 text boxes, Im using Data merge to fill these fields.

My question has 2 parts:

Part 1 of my question is -  What script can I use to export these 200 certificates to seperate pdfs

Part 2 of my question is - What script can I utilise to make use of one of the fields which will be (name) and use that to name the file when it is exported?

Much appreciated...

Darren.

이 주제는 답변이 닫혔습니다.
최고의 답변: Loic.Aigon

Hi,

You may want to try two scripts I wrote :

Export single PDFs file :

http://www.scriptopedia.org/index.php?post/custompdfexport.jsx.html

use some csv row to rename a bunch of pdf files accordingly:

var csv=File(Folder.desktop+"/fichier.csv");

var myPDFFolder = Folder(Folder.desktop+"/pdfs");

var names = getNamesFromCSV(csv);

if(csv.exists && myPDFFolder.exists){
   
var files = myPDFFolder.getFiles();
   
if(files.length==names.length){
       
for(var i=0; i<files.length; i++){
            files
[i].rename(files[i].parent+"/"+names[i]+".pdf");
       
}
   
}
}
       
function getNamesFromCSV(csv){
   
if(csv.exists){
        csv
.open('r');
       
var content = csv.read();
       
var namesArr = [];
        content
=content.split("\n");
       
for(var j=0; j<content.length; j++){
            namesArr
.push(content[j].match(/^(.[^\n]+)/i)[1]);
       
}
           
        csv
.close();
       
return namesArr.slice(1,namesArr.length);
   
}
   
return false;
}

This code was intented to use the first row item as the basis for renaming the PDF files. Adapt it to your own needs.

Hope it helps,

Loic

http://www.loicaigon.com

http://www.scriptopedia.org

1 답변

Loic.Aigon
Legend
February 18, 2011

Hi,

You may want to try two scripts I wrote :

Export single PDFs file :

http://www.scriptopedia.org/index.php?post/custompdfexport.jsx.html

use some csv row to rename a bunch of pdf files accordingly:

var csv=File(Folder.desktop+"/fichier.csv");

var myPDFFolder = Folder(Folder.desktop+"/pdfs");

var names = getNamesFromCSV(csv);

if(csv.exists && myPDFFolder.exists){
   
var files = myPDFFolder.getFiles();
   
if(files.length==names.length){
       
for(var i=0; i<files.length; i++){
            files
[i].rename(files[i].parent+"/"+names[i]+".pdf");
       
}
   
}
}
       
function getNamesFromCSV(csv){
   
if(csv.exists){
        csv
.open('r');
       
var content = csv.read();
       
var namesArr = [];
        content
=content.split("\n");
       
for(var j=0; j<content.length; j++){
            namesArr
.push(content[j].match(/^(.[^\n]+)/i)[1]);
       
}
           
        csv
.close();
       
return namesArr.slice(1,namesArr.length);
   
}
   
return false;
}

This code was intented to use the first row item as the basis for renaming the PDF files. Adapt it to your own needs.

Hope it helps,

Loic

http://www.loicaigon.com

http://www.scriptopedia.org

Smart_77작성자
Participant
February 18, 2011

Thanks alot