Delay Indesign Saving a Document

Post Reply
jlisle_PointB
Newbie
Posts: 1
Joined: Tue Sep 26, 2023 7:57 pm

Delay Indesign Saving a Document

Post by jlisle_PointB »

Hello I'm new to Switch and working with one of our in house web developers to come up with a script to have the Indesign Configurator wait 1 minute before it closes and saves the open file as the same name. The goal is to have the file open long enough to auto-activate Adobe fonts in Creative Suite.

Here's the script we come up for the "Save as" in the InDesign Configurator that doesn't seem to be working:

let doc = $doc;
let $outfiles = [];

try {
setTimeout(function() {
let $outfile = new File(`${$outfolder}/${$filename}.${$extension}`);
doc.saveAs($outfile);
$outfiles.push(`${$outfolder}/${$filename}.${$extension}`);
}, 60000)

} catch (error) {
doc.close(SaveOptions.DONOTSAVECHANGES);
$error = error.description;
}

Any ideas how to fix this script or to achieve activating Adobe fonts for InDesign?

Thank you.
jan_suhr
Advanced member
Posts: 581
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Delay Indesign Saving a Document

Post by jan_suhr »

You have the "Use font in package" property if set to yes it will use fonts that come along the file in a package. If that's the way you get the InDesign file.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
freddyp
Advanced member
Posts: 1000
Joined: Thu Feb 09, 2012 3:53 pm

Re: Delay Indesign Saving a Document

Post by freddyp »

The Indesign API has an updateFonts method at the Application level. I am not sure it does what you want but it is worth a try. I have not tested it, but the line should be:

Code: Select all

app.updateFonts();
There is also a waitForAllTasks method. Could this do the trick?

A good site for consulting the complete API is this one: https://www.indesignjs.de/extendscriptA ... ation.html
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Delay Indesign Saving a Document

Post by Padawan »

I have used the following line in the past for font activation with extensis

$.sleep(10000)
(Unit is milliseconds)

You might want to try freddys suggestion first, if it works it won't need delays.
loicaigon
Advanced member
Posts: 340
Joined: Wed Jul 10, 2013 10:22 am

Re: Delay Indesign Saving a Document

Post by loicaigon »

For what it's worth, using $.sleep() in InDesign Scripts is quite useless as it freezes script execution (and by extension any InDesign operations).
smitham59
Newbie
Posts: 1
Joined: Thu Jan 18, 2024 5:57 am

Re: Delay Indesign Saving a Document

Post by smitham59 »

freddyp wrote: Thu Oct 12, 2023 8:35 am The Indesign API has an updateFonts method at the Application level. I am not sure it does what you want but it is worth a try. I have not tested it, but the line should be:

Code: Select all

app.updateFonts();
There is also a waitForAllTasks method. Could this do the trick?

A good site for consulting the complete API is this one: https://www.indesignjs.de/extendscriptAgetaway shootout...ation.html
As far as I know:

Regarding

Code: Select all

updateFonts()
Purpose: It's designed to refresh InDesign's internal font list, ensuring it reflects the latest state of available fonts on the system. This can be useful in scenarios like:
New fonts being installed or activated.
Fonts being modified or removed.
Resolving font-related issues that might arise due to inconsistencies.
Usage:
Access the

Code: Select all

Application
object:

Code: Select all

var app = Application.activeApplication();
Call the method:

Code: Select all

app.updateFonts();
Regarding

Code: Select all

waitForAllTasks():
Purpose: Pauses script execution until all pending tasks within InDesign have completed. This can be helpful for:
Ensuring actions that might affect fonts have fully finished before proceeding.
Avoiding potential conflicts or errors.
Usage:
Call the method:

Code: Select all

app.waitForAllTasks();
Using them together:

To potentially address font-related issues, try combining them:

Code: Select all

JavaScript
app.updateFonts();
app.waitForAllTasks();
Post Reply