Copy link to clipboard
Copied
Hello All,
I am struggling to write a script to save the ".indd" file into other two formats ".idml" and ".pdf".
For Example:
1) File Name " Artwork.indd" is the source file. I need to change some contents in the file.
2) After the changes, I need to save the existing "Artwork.indd" file in the default location.
3) Also, I need to save the file as "Artwork.idml" and "Artwork.pdf" in the same existing folder.
Please help me to figure out the script to overcome this situation.
Hi,
In the script you want to do the following
for IDML:
Use the exportFile command and pass ExportFormat.INDESIGN_MARKUP
for PDF:
Use the exportFile commend and pass ExportFormat.PDF_TYPE.
And you need to specify a PDFExportPreset, you can see the ones in the File->Adobe PDF Presets menu.
link to the documentation - https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html#d1e49413__d1e53790
// code would be something like
app.activeDocument.exportFile ( ExportFormat.P
...
Hi Vaithiyanathan J,
for the file argument, the second one of method exportFile() , you could use the document itself as a starting point.
var doc = app.activeDocument;
var docFile = File( doc.fullName );
var docPath = docFile.parent;
var idmlFileName = doc.name.replace(/\.indd$/i , ".idml" );
var idmlFile = File( docPath +"/"+idmlFileName );
var pdfFileName = doc.name.replace(/\.indd$/i , ".pdf" );
var pdfFile = File( docPath +"/"+pdfFileName );
Note: Make sure that the InDesign document
...Hi @Surya24 ,
var pdfExportPreset = ""; //Kindly assign name of the pdf preset.
if (!(app.documents.length)) {
alert("Open your indesign file.");
exit(0);
}
var doc = app.documents[0];
doc.save();
var docFile = new File(doc.fullName);
var docPath = docFile.parent;
var docName = doc.name.replace(/\.indd$/i, "");
var idmlFile = new File(docPath + "/" + docName + ".idml");
var pdfFile = new File(docPath + "/" + docName + ".pdf");
doc.exportFile(ExportFormat.INDESIGN_MARKUP, idmlFile);
if
...
Copy link to clipboard
Copied
Hi,
In the script you want to do the following
for IDML:
Use the exportFile command and pass ExportFormat.INDESIGN_MARKUP
for PDF:
Use the exportFile commend and pass ExportFormat.PDF_TYPE.
And you need to specify a PDFExportPreset, you can see the ones in the File->Adobe PDF Presets menu.
link to the documentation - https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html#d1e49413__d1e53790
// code would be something like
app.activeDocument.exportFile ( ExportFormat.PDF_Type, "path_to_export_to", false, PDFExportPreset, "version", true);
Copy link to clipboard
Copied
Thank you so much
Copy link to clipboard
Copied
Hi Vaithiyanathan J,
for the file argument, the second one of method exportFile() , you could use the document itself as a starting point.
var doc = app.activeDocument;
var docFile = File( doc.fullName );
var docPath = docFile.parent;
var idmlFileName = doc.name.replace(/\.indd$/i , ".idml" );
var idmlFile = File( docPath +"/"+idmlFileName );
var pdfFileName = doc.name.replace(/\.indd$/i , ".pdf" );
var pdfFile = File( docPath +"/"+pdfFileName );
Note: Make sure that the InDesign document is already saved at least once so that you will not get an error at doc.fullName. Also note, that there is a second method for exporting files: asynchronousExportFile() that also takes a file as the second argument.
DOM documentation compiled by Gregor Fellenz:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thank you so much for your response
Copy link to clipboard
Copied
Hi @Surya24 ,
var pdfExportPreset = ""; //Kindly assign name of the pdf preset.
if (!(app.documents.length)) {
alert("Open your indesign file.");
exit(0);
}
var doc = app.documents[0];
doc.save();
var docFile = new File(doc.fullName);
var docPath = docFile.parent;
var docName = doc.name.replace(/\.indd$/i, "");
var idmlFile = new File(docPath + "/" + docName + ".idml");
var pdfFile = new File(docPath + "/" + docName + ".pdf");
doc.exportFile(ExportFormat.INDESIGN_MARKUP, idmlFile);
if (pdfExportPreset != "") {
doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, pdfExportPreset);
}
else {
doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, true);
}
Copy link to clipboard
Copied
Thank you so much for your response
Copy link to clipboard
Copied
Why not use the Package feature it does all of them in a neat little folder. It also will point out any potential problems.