Article View: adobe.scripting.indesign
Article #1741Loop through all open documents not performing some actions
From: matt_p_stone
Date: Wed, 28 Jan 2009 16:36
Date: Wed, 28 Jan 2009 16:36
21 lines
2133 bytes
2133 bytes
I have a loop that imports XML, then Exports each page individually, then has a SaveAs dialog for the indd, then closes the active document.
The import XML works, the SaveAs works, and the close works but the loop skips over the PDF part. Is it because I need to define myCounter in the for loop within the ExportPDF function? I just included the part from Choose XML to the end of ExportPDF.
//choose XML
var FilterXML = "XML File: *.xml";
var myXML = File.openDialog("Choose XML File", FilterXML);
//loop for each action below
for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
//import XML
app.activeDocument.importXML(myXML);
//PDF by page to settings; preset must be "dailies_x1a"
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myBaseName = myBaseNameField.editContents;
for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){ myPageName = myDocument.pages.item(myCounter).name; app.pdfExportPreferences.pageRange = myPageName; //The name of the exported files will be the base name + the page name + ".pdf". //If the page name contains a colon (as it will if the document contains sections), then remove the colon. var myRegExp = new RegExp(":","gi"); myPageName = myPageName.replace(myRegExp, "_"); myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf"; myFile = new File(myFilePath); myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a"); } }
Technical Details
Message-ID:
<59b7b609.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,4de4ad86a3e3d96c,start X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: matt_p_stone@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Loop through all open documents not performing some actions Message-ID: <59b7b609.-1@webcrossing.la2eafNXanI> Date: Wed, 28 Jan 2009 08:36:57 -0800 Lines: 41 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit