Copy link to clipboard
Copied
Whereas v18.3 worked completely fine, something in InDesign 18.4 broke the API.
Not even Adobes own "Getting started guide" works anymore.
Take this for example: "Setting up measurement units and master spread margins"
The code-snippet to copy will fail with an error "app is not available". in v18.3 and before, "app" was available globally
var myDocument = app.documents.add();
//Set the measurement units and ruler origin.
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
To fix this first issue, you can import `app`manually like so:
const idd = require("indesign");
const app = idd.app;
var myDocument = app.documents.add();
//Set the measurement units and ruler origin.
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
This however will just fail with an error: "MeasurementUnits" is not defined.
The same problem occurs, if you try something like this, which has been working for years and is even referenced in Adobes own "Recipies", because "NothingEnum" is not available.
...
app.findGrepPreferences = NothingEnum.nothing;
...
So is there something I've missed in the patch-notes? Or worse, is this behavior intentional?? If the latter, you should update the aforementioned guides...
Hope you can fix this soon, until then we'll have to stick with v18.3
@B_I MEDIEN All the global objects have moved under the object returned by require("indesign")
In the code snippet shared by you, they are available under idd object.
const idd = require("indesign");
const app = idd.app;
var myDocument = app.documents.add();
myDocument.viewPreferences.horizontalMeasurementUnits = idd.MeasurementUnits.points;
And yes, this is incorrectly represented in the documentation. This will be fixed soon.
Copy link to clipboard
Copied
@B_I MEDIEN All the global objects have moved under the object returned by require("indesign")
In the code snippet shared by you, they are available under idd object.
const idd = require("indesign");
const app = idd.app;
var myDocument = app.documents.add();
myDocument.viewPreferences.horizontalMeasurementUnits = idd.MeasurementUnits.points;
And yes, this is incorrectly represented in the documentation. This will be fixed soon.