Copy link to clipboard
Copied
Hey guys,
i have a script that automatically make a .idml file every time i make a .pdf from indesign. I am on CC2018 indesign MAC. however, the script does not work for another person on CC2018 in windows. can somebody tell me what is wrong? here is the code:
// Export-IDML-after-export-to-PDF.jsx
( function()
{
#targetengine "Kasyan-Uwe"
var eventListenerName = "Export-IDML-after-export-to-PDF";
var eventListener = app.eventListeners.itemByName( eventListenerName );
if( eventListener.isValid )
{
eventListener.remove();
alert
(
eventListenerName +"\r"+
"Script was canceled."+"\r"+
"Note: To start the script, double-click it again." +"\r"+
"It's a toggle function."
);
return;
};
var eventListener = app.addEventListener("beforeExport", exportIDMLafterPDFexport, false);
eventListener.name = eventListenerName;
alert
(
eventListenerName +"\r"+
"Script was started."+"\r"+
"Note: To cancel the script, double-click it again." +"\r"+
"It's a toggle function."
);
function exportIDMLafterPDFexport(event)
{
var exportedFile = event.fullName;
var exportFolder = exportedFile.parent;
var doc = event.parent;
var idmlFileName = doc.name.replace(/\.indd$/, ".idml" );
var idmlFile = File(exportFolder+"/"+idmlFileName);
if( exportedFile.name.match(/\.pdf$/i))
{
doc.asynchronousExportFile( ExportFormat.INDESIGN_MARKUP , idmlFile , false );
};
}
}() )
Copy link to clipboard
Copied
Hi Jonathan,
The script works fine for me on CC2018 WIN. What error do you get? Also remember the script works in a toggle manner i.e. double click once activates its and double click again deactivates it, maybe that person is missing this point.
-Manan
Copy link to clipboard
Copied
Hmm. We did a share screen and I watched them, it did not work. would The OS they are on make a difference?
Copy link to clipboard
Copied
What happens, any errors? Maybe you could try debugging the script using ExtendScript. See if the breakpoint hits in the exportIDMLafterPDFexport method and then you can check the paths and their validity as suggested by Trevorׅ
-Manan
Copy link to clipboard
Copied
well. i watched them. they double click on the script. i see the alert telling you is one. they open an indesign file, saved a new version, exported a .pdf, but the .idml file was not created.
Copy link to clipboard
Copied
Hello Jonathan,
Lets try to debug it remotely, i am putting a version of the script with alerts put in place to trace the flow of code. Please ask your client to run and share a screencast of the whole process here. We should hopefully get some hint from that based on how many alerts are triggered
// Export-IDML-after-export-to-PDF.jsx
( function()
{
#targetengine "Kasyan-Uwe"
var eventListenerName = "Export-IDML-after-export-to-PDF";
var eventListener = app.eventListeners.itemByName( eventListenerName );
if( eventListener.isValid )
{
eventListener.remove();
alert
(
eventListenerName +"\r"+
"Script was canceled."+"\r"+
"Note: To start the script, double-click it again." +"\r"+
"It's a toggle function."
);
return;
};
var eventListener = app.addEventListener("beforeExport", exportIDMLafterPDFexport, false);
eventListener.name = eventListenerName;
alert
(
eventListenerName +"\r"+
"Script was started."+"\r"+
"Note: To cancel the script, double-click it again." +"\r"+
"It's a toggle function."
);
function exportIDMLafterPDFexport(event)
{
alert("Callback called")
var exportedFile = event.fullName;
var exportFolder = exportedFile.parent;
var doc = event.parent;
alert("exportedFile " + exportedFile)
alert("exportFolder " + exportFolder)
var idmlFileName = doc.name.replace(/\.indd$/, ".idml" );
var idmlFile = File(exportFolder+"/"+idmlFileName);
alert("idmlFileName " + idmlFileName)
alert("idmlFile " + idmlFile)
if( exportedFile.name.match(/\.pdf$/i))
{
alert("Now exporting IDML")
doc.asynchronousExportFile( ExportFormat.INDESIGN_MARKUP , idmlFile , false );
}
}
}() )
-Manan
Copy link to clipboard
Copied
What Manan Joshi said is quite possibly correct.
Another possibility is the path being used particularly some paths like desktop. Try using .fsName for the path.
"/" should work for Windows but you can try "\\" out of desperation.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now