-
1. Re: Export all open docs as PDF
Adobe-InDesign CS4 Aug 7, 2011 10:13 PM (in response to Ramjivk)Dear Ramji
Please use the below code for solving your problem:
//===================== Start : Export =================================//
var myTotalDocs = (app.documents.length);
for(var i = 0; i < myTotalDocs; i++)
{
myDocument = app.documents[i];
app.activeDocument = myDocument;
var myFilePath = app.activeDocument.filePath;
app.activeDocument.exportFile(ExportFormat.pdfType, File(myFilePath+"/"+".pdf"),false);
myDocument.close(SaveOptions.NO);
}//===================== End: Export =================================//
Once Export the InDesign open document then immediatly close... otherwise this problem [what you menditoned] will occure.
Thanks & Regards
T.R.Harihara SudhaN
-
2. Re: Export all open docs as PDF
Ramjivk Aug 8, 2011 6:05 AM (in response to Adobe-InDesign CS4)I have tried the code, but it throws an error message
Error number: 30477
Error string: Invalid value for set property "activeDocument". Expected Document, but received nothing.
Source: app.activeDocument = myDocument;
Please help
-
3. Re: Export all open docs as PDF
csm_phil Aug 8, 2011 7:31 AM (in response to Ramjivk)Hi Ramjivk,
Please try the below JS Code, i hope you expected this!
while(app.documents.length>0){ var myDoc = app.activeDocument; myDoc=myDoc.filePath+"/"+myDoc.name.split(".indd").join(".pdf"); //alert(myDoc); var exportfile=new File(myDoc); app.activeDocument.exportFile(ExportFormat.pdfType, exportfile, false); app.activeDocument.close(); }thx
csm_phil
-
4. Re: Export all open docs as PDF
Ramjivk Aug 8, 2011 9:40 AM (in response to csm_phil)Hi csm_phil,
Thank you so much. Its working.
It will be great if you can explain what could be the problem?
Regards
Ramji V K
-
5. Re: Export all open docs as PDF
Ramjivk Aug 8, 2011 9:40 AM (in response to Ramjivk)Thanks for the support
-
6. Re: Export all open docs as PDF
[Jongware] Aug 8, 2011 2:27 PM (in response to Ramjivk)Ramjivk wrote:
It will be great if you can explain what could be the problem?
If you have seven documents and you close the first one after processing, what are the array indexes of the ones left?
(None of the above posters got it right; cms_phil avoided this problem.)
-
7. Re: Export all open docs as PDF
Ramjivk Oct 4, 2013 9:10 PM (in response to [Jongware])Hi Jongware,
I removed the below code from the script.
var myTotalDocs = (app.documents.length);
so, i will not have any array. If i have seven docs, i export the first doc as PDF and close that. so that InDesign does not export the same doc again and again.
thanks.
-
8. Re: Export all open docs as PDF
csm_phil Oct 5, 2013 12:17 AM (in response to Ramjivk)Hi Ramjivm,
I think the problem is forward loop, If you use the reverse loop the problem is solved.
var myTotalDocs = (app.documents); for(var i = myTotalDocs.length-1; i>=0; i--){ myDocument = app.documents[i]; app.activeDocument = myDocument; var myFilePath = String(app.activeDocument.fullName); app.activeDocument.exportFile(ExportFormat.pdfType, new File(myFilePath.replace(".indd", ".pdf")),false); app.activeDocument.close(); }thx,
csm_phil



