Thread View: adobe.scripting.indesign
5 messages
5 total messages
Started by James_Leyland
Wed, 11 Feb 2009 12:40
Export individual PDFs and save to a specified folder location?????
Author: James_Leyland
Date: Wed, 11 Feb 2009 12:40
Date: Wed, 11 Feb 2009 12:40
48 lines
2229 bytes
2229 bytes
=====================================================================
Export individual PDFs and save to a specified folder location?????
=====================================================================
Hey guys,
I was wondering if anyone knows of a way in which I can get Indesign CS3 to save to a specified location when exporting a PDF?
I am currently using a data merge prior to running my java script to export a set number of pages to individual PDFs, but i am struggling to get it to save these PDFs to a specified folder location.
The code I am using to export the PDFs looks like this:
var SectionLength = 4;
for (var p=0; p<app.activeDocument.pages.length; p += SectionLength)
{
var currentpage = app.activeDocument.pages[p];
var textframe = currentpage.textFrames.item("Company Name");
var companyname = textframe.contents;
var textframe2 = currentpage.textFrames.item("PDF Description");
var pdfdescription = textframe2.contents;
//alert(textframe.contents);
with(app.pdfExportPreferences)
{
if (p+SectionLength-1 > app.activeDocument.pages.length)
pageRange = app.activeDocument.pages[p].name+"-"+app.activeDocument.pages[app.activeDocument.pages.length-1].name;
else
pageRange = app.activeDocument.pages[p].name+"-"+app.activeDocument.pages[p+SectionLength-1].name;
theFile = new File(companyname+" - "+pdfdescription+".pdf");
app.activeDocument.exportFile (ExportFormat.pdfType, theFile, false);
}
}
Any help would be great as I'm new to this scripting stuff and can't quite get it too work.
Thanks very much for your help!
James
Re: Export individual PDFs and save to a specified folder location?????
Author: Peter Kahrel
Date: Wed, 11 Feb 2009 13:15
Date: Wed, 11 Feb 2009 13:15
6 lines
783 bytes
783 bytes
Just prefix the folder name to the file name: var dir = '/d/pdf_output/' theFile = new File(dir + companyname+" - "+pdfdescription+".pdf"); Peter
Re: Export individual PDFs and save to a specified folder location?????
Author: James_Leyland
Date: Wed, 11 Feb 2009 15:36
Date: Wed, 11 Feb 2009 15:36
16 lines
1082 bytes
1082 bytes
Hey Peter, Thanks for responding. By prefixing it in that manner it simply changes the file name to something like: d/pdf_out/companyname - pdfdescription.pdf It also doesn't appear to save it to the specified location. I would like the file name to stay the same as it is, but then save it to the directory (folder). Any further help you can give would be greatfully recieved. Thanks very much again! James
Re: Export individual PDFs and save to a specified folder location?????
Author: Peter Kahrel
Date: Wed, 11 Feb 2009 15:46
Date: Wed, 11 Feb 2009 15:46
10 lines
977 bytes
977 bytes
With a file name like
/d/pdf_out/companyname - pdfdescription.pdf
the file companyname - pdfdescription.pdf is stored in the directory /d/pdf_out/ ( or d:\out\ in PC notation, but tiou should still use /d/pdf_out/ in JavaScript). Did you include that initial slesh? That should be there.
Peter
Re: Export individual PDFs and save to a specified folder location?????
Author: James_Leyland
Date: Wed, 11 Feb 2009 16:11
Date: Wed, 11 Feb 2009 16:11
10 lines
823 bytes
823 bytes
Hey Peter, Ah I see! Sorry I was being a bit rubbish with the script (as mentioned, a bit new to this). That's absolutely brilliant, it now works! Thanks very much for all your help! James
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads