Skip to main content
Known Participant
June 16, 2020
Question

InDesigns cancels processing on click

  • June 16, 2020
  • 6 replies
  • 830 views

 

Hello,

 

I have an extension that has a process that takes a few minutes (exporting to a pdf).  

 

If the user clicks anywhere in InDesign while the export is running, InDesign just kills the process immidiatly.  This leaves the export files locked since it is not a gracious cancel and just leaves the user wondering what happened.

 

Is there any way to prevent this?  Force InDesign to wait until the process is done in the extension?

 

Than you!!

 

This topic has been closed for replies.

6 replies

brian_p_dts
Community Expert
Community Expert
July 1, 2020

My only advice might be to run a progress bar while the export is happening so the user knows not to click while it's happening. Show the progress bar before the export occurs and destroy it after the export is complete. Could include a note on the bar title to not touch anything while processing. Does the export successfully happen if no one touches it? 

Known Participant
July 1, 2020

Yes, the export works well if no one touches it.

 

If someone touches it the next process gets an end of file exception.

 

Thank you!

Community Expert
July 1, 2020

Ok, Jorge,

I know of one case where the PDF export is affected with erratic clicks in the UI during exportFile():

If the document contains placed AI files, then it could happen that the graphics are missing in the exported PDF.

It never happened to me, that the whole export was canceled by that. That's new to me.

 

The only suggestion I can do now is to use asynchronousExportFile() instead where the user has full access to menus and tools with InDesign. You could check if the exported file is fully written by e.g. looking more or less constantly at its file size perhaps. Or you would run the whole thing with a ScriptUI that blocks the user from doing anything else, because you go with a modal interface. For example a "dialog" type of window.*

 

More details on scriptUI by Peter Kahrel here:

https://creativepro.com/files/kahrel/indesign/scriptui.html

 

* Sorry. Scratch this idea. If a modal dialog is open the script would do nothing until the user OKed or canceled the dialog.

 

Regards,
Uwe Laubender

( ACP )

 

Legend
July 1, 2020

Hello,

 

RE: "You could check if the exported file is fully written by e.g. looking more or less constantly at its file size perhaps."

 

you can try this when exporting the pdf and before moving on in your code.

 

var saveOpts = app.pdfExportPresets.itemByName(preset);
app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
task = template.asynchronousExportFile(ExportFormat.PDF_TYPE, pdfFile, false, saveOpts);
task.waitForTask();
 
Regards
Mike
Community Expert
July 1, 2020

Hi Jorge,

so how exactly do you do this export?

What is the ExtendScript method you are using right now?

 

FWIW: My suggestion was to use method exportFile() over asynchronousExportFile().

 

Regards,
Uwe Laubender

( ACP )

Known Participant
July 1, 2020

Hi Uwe,

 

Oh, I misread.

 

...
var saveOpts = app.pdfExportPresets.itemByName(preset);
app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
template.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, saveOpts);
 
The blue line is the one that takes a while to process and where it breaks/stops if someone clicks anywhere inside InDesign.
 
Jorge
 
 
 
Sheena Kaul
Legend
June 26, 2020

Hi there,

 

I am hoping that your issue has been resolved till now. If not, please feel free to update this thread else let us know if any of the suggestions shared above helped you or not.

 

Regards,

Sheena

Known Participant
July 1, 2020

Hi Sheena,

 

I am still experiencing the problem. It only happens in windows.

 

Some PDFs take a few minutes to export, and if the user just clicks anywhere on InDesign it cancels the process.

 

Any ideas will be appreciated.

 

Jorge

Community Expert
June 17, 2020

Hi JG10,

you said: "…Force InDesign to wait until the process is done in the extension?"

Hm. I assume you do the export with ExtendScript method asynchronousExportFile().

You could try this with the older method exportFile() instead that will not use a background process.

 

Regards,
Uwe Laubender

( ACP )

Known Participant
July 1, 2020

Hi Uwe,

 

Thank you for your response.  Unfortunatelly, I can't do this asynchronusly since there is a process that runs after the export is completed.

 

Thank you, Jorge

Peter Kahrel
Community Expert
Community Expert
June 16, 2020

"Doctor, my shoulder hurts when I raise my hand."

"Don't raise your hand!"

 

In other words, 'Don't touch your mouse while the script is running!'. But, seriously, you should ask the author of the extension about the problem.

P.

Known Participant
June 16, 2020

Thank you Peter for your answer.

 

The thing is I wrote the extension and I did not put any code to do such a thing.  I am trying to figure out if I can prevent it somehow from happening.

 

I forgot to mention that this only happens in windows. The extension runs fine on a mac

J.