Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

script not working on windows

Guru ,
Dec 12, 2018 Dec 12, 2018

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 ); 

        }; 

    } 

 

}() ) 

TOPICS
Scripting
549
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2018 Dec 12, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 13, 2018 Dec 13, 2018

Hmm. We did a share screen and I watched them, it did not work. would The OS they are on make a difference?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2018 Dec 13, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 13, 2018 Dec 13, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2018 Dec 13, 2018
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 13, 2018 Dec 13, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines