Skip to main content
Participating Frequently
November 19, 2016
Question

Completing track changes before export

  • November 19, 2016
  • 1 reply
  • 620 views

I am trying to accept all changes in a document, and then export the result to IDML.  (goal is to perform the task on a batch of files at the same time).

I am using the following code:

app.documents[0].stories.everyItem().changes.everyItem().accept();

exportIdm(app.documents[0]);

function exportIdml(theDocument)

{

      myFilePath = theDocument.name + ".idml";

      myFile = new File(myFilePath);

      theDocument.exportFile(ExportFormat.INDESIGN_MARKUP, myFile, false);

}

If I try only to accept all changes, or simply to export IDML, with part of the above code, I get expected result.

However, if I run both in the same script, InDesign hangs, and I get an invalid frame when InDesign restart and recover the document.

It looks like the app.documents[0].stories.everyItem().changes.everyItem().accept() action is not completely committed before the next function is called.

Note that in my test document, there are a large number of changes, including over 600 frames tracked for deletion, which can be a contributing factor.

Any clue on how I can force the accept() to complete and commit the changes before running the IDML export? 

This topic has been closed for replies.

1 reply

Peter Kahrel
Community Expert
Community Expert
November 20, 2016

You can make the script wait for a few seconds:

$.sleep (n);

where n is the number of milliseconds to wait.

By the way, myFilePath = theDocument.name + 'idml' is misleading in that you return the document's name without the path.

Peter

Participating Frequently
November 22, 2016

Thank you for your input, but that did not help.

I also tried to save the document from within the script, but with similar results..

As a side note, the file path info shown in my example is not in the final format.  In the full program, I perform the idml export for an entire folder, where I include the full path for that folder.  This complete program works well if I only perform the idml export, but fail if I add the line to accept all the changes.

tpk1982
Legend
November 22, 2016

What will happen to do like below?

exportIdm(app.documents[0]);

function exportIdml(theDocument)

{

       app.documents[0].stories.everyItem().changes.everyItem().accept();

           myFilePath = theDocument.name + ".idml";

      myFile = new File(myFilePath);

      theDocument.exportFile(ExportFormat.INDESIGN_MARKUP, myFile, false);

}