# UXP and ExtendScript — InDesign Server

> Adobe InDesign Server 2025 (20.5.0.49) Object Model. How the object model in this reference is used from UXP, and where that differs from ExtendScript.

InDesign runs scripts in two engines. **ExtendScript** (`.jsx`) is the original one: JavaScript at the level of ES3, with `app` and every enumeration as globals. **UXP** (`.idjs` scripts; UXP plugins since 18.5) is modern JavaScript. Both drive the same object model — the classes, properties and methods documented here. What differs is how you reach it and a handful of rules around it.

## Reaching the object model

```js
const { app, PathType } = require("indesign");

async function main() {
  const doc = app.activeDocument;
  const page = doc.pages.item(0);        // not doc.pages[0]
  const path = page.polygons.item(0).paths.item(0);
  if (path.pathType.equals(PathType.CLOSED_PATH)) {   // not ==
    console.log("closed");
  }
  const file = await doc.fullName;      // a Promise under UXP
  console.log(file.nativePath);
}
main();
```

## Rules

| | ExtendScript | UXP |
| --- | --- | --- |
| `app`, enumerations | globals | `require("indesign")` |
| Collection item | `pages[0]` or `pages.item(0)` | `pages.item(0)` only — `[]` does not exist |
| Compare enumerations, DOM objects | `==` | `.equals()` — `==` and `===` do not work |
| Files and folders | ExtendScript `File`, `Folder` | entries from `require("uxp").storage` |
| Reading a file or folder property | the object | a Promise — `await` it |
| Passing a file | `File` | path string or UXP `File` entry |
| Passing a folder | `Folder` | path string only |
| Does a DOM object have a property? | `obj.hasOwnProperty("name")` or `"name" in obj` | `"name" in obj` only — `hasOwnProperty()` and `Object.hasOwn()` are always `false` |
| Script arguments | `app.scriptArgs.getValue("name")`; `arguments` in a script run by `doScript()` | `require("uxp").script.args` — an array of strings; `app.scriptArgs` is `undefined` |
| Script result | the value of the last expression | `script.setResult(value)` — the last expression is ignored |
| Event handler | function or `File` | function, or the path of a `.jsx` as a string — that script runs as ExtendScript |
| Output | `$.writeln()` | `console.log()` |
| User interface | ScriptUI | HTML |
| Not available | — | `$`, ScriptUI, `XML`/`XMLList` (E4X), `Socket`, `UnitValue`, `Reflection` |

`app.doScript()` still runs an ExtendScript file from UXP. Its `withArguments` reach an ExtendScript as `arguments` with their types, a UXP script as strings in `script.args` (`true` becomes `"TRUE"`). `doScript()` returns the called script's result: the last expression of an ExtendScript, the `script.setResult()` value of a UXP script.

## InDesign Server: arguments and result

A server script runs on behalf of a client, so both ends matter: what the client passes in and what the script hands back. The two engines do both differently.

- **Arguments.** ExtendScript reads them from `app.scriptArgs`. UXP gets them in `require("uxp").script.args` as an array of `"name=value"` strings; `app.scriptArgs` does not exist there. [Adobe: passing arguments](https://developer.adobe.com/indesign/uxp/scripts/tutorials/arguments/)
- **Result.** ExtendScript returns the value of the last expression to the client. UXP returns only what the script passes to `script.setResult()`. [Adobe: script result](https://developer.adobe.com/indesign/uxp/scripts/tutorials/script-result/)

```js
// server.jsx
var args = app.scriptArgs;
var name = args.isDefined("name") ? args.getValue("name") : "World";
var doc = app.documents.add();
var frame = doc.pages[0].textFrames.add();
frame.geometricBounds = [20, 20, 40, 120];
frame.contents = "Hello " + name;
frame.paragraphs[0].justification = Justification.CENTER_ALIGN;
var result = frame.contents;
doc.close(SaveOptions.NO);
result; // returned to the client
```

```js
// server.idjs
const { app, Justification, SaveOptions } = require("indesign");
const { script } = require("uxp");
const arg = script.args.find(a => a.startsWith("name="));
const doc = app.documents.add();
const frame = doc.pages.item(0).textFrames.add();
frame.geometricBounds = [20, 20, 40, 120];
frame.contents = "Hello " + (arg ? arg.slice(5) : "World");
frame.paragraphs.item(0).justification = Justification.CENTER_ALIGN;
const result = frame.contents;
doc.close(SaveOptions.NO);
script.setResult(result); // returned to the client
```

## How this reference marks the differences

- Markdown: a type that differs carries `(UXP: …)`, for example `File` (UXP: `Promise<File>`). Methods that do not exist under UXP say _ExtendScript only — not available in UXP._ Runtime notes start with **UXP:**.
- [api.json](https://www.indesignjs.de/indesignapi/indesign-server/api.json): `runtimes` lists both engines. A member that differs has `uxp: { type }`, `uxp: { returns }` or `uxp: { available: false }`; notes are `notes: [{ runtime, text }]`.
- The website has an ExtendScript / UXP switch in the header that shows every page as the chosen engine sees it.
- The `.d.ts` files here describe ExtendScript. For UXP type declarations use [indesign-uxp-types](https://www.npmjs.com/package/indesign-uxp-types).

## File and folder values that are Promises under UXP

30 members. Measured at runtime in InDesign 2026 (indesign-uxp-types).

- `Application.activeScript` → `Promise<File>`
- `Application.filePath` → `Promise<Folder>`
- `Application.fullName` → `Promise<File>`
- `Assignment.documentPath` → `Promise<File>`
- `Assignment.createPackage()` returns `Promise<File>`
- `Book.filePath` → `Promise<Folder>`
- `Book.fullName` → `Promise<File>`
- `BookContent.filePath` → `Promise<Folder>`
- `BookContent.fullName` → `Promise<File>`
- `ColorSetting.cmsSettingsPath` → `Promise<File>`
- `Document.filePath` → `Promise<Folder>`
- `Document.fullName` → `Promise<File>`
- `Document.mtPrepareDOCX()` returns `Promise<File>`
- `DocumentEvent.fullName` → `Promise<File>`
- `EventListener.handler` → `Promise<File>`
- `GeneralPreference.temporaryFolder` → `Promise<Folder>`
- `HyperlinkExternalPageDestination.documentPath` → `Promise<File>`
- `ImportExportEvent.fullName` → `Promise<File>`
- `Library.filePath` → `Promise<Folder>`
- `Library.fullName` → `Promise<File>`
- `PDFExportPreset.fullName` → `Promise<File>`
- `PrintBookletPrintPreference.printFile` → `Promise<File>`
- `PrintPreference.printFile` → `Promise<File>`
- `PrinterPreset.printFile` → `Promise<File>`
- `ScriptPreference.scriptsFolder` → `Promise<Folder>`
- `ServerSetting.iorFile` → `Promise<File>`
- `ServerSetting.pluginPaths` → `Promise<File>`
- `XMLExportPreference.preferredBrowser` → `Promise<File>`
- `XMLExportPreference.transformFilename` → `Promise<File>`
- `XMLImportPreference.transformFilename` → `Promise<File>`

## String or File: only the String under UXP

Adobe types these as `String | File`. Under UXP they return the path as a string.

- `AssignedStory.filePath`
- `Assignment.filePath`
- `GotoAnchorBehavior.filePath`
- `Link.filePath`
- `Movie.filePath`
- `OpenFileBehavior.filePath`
- `Sound.filePath`

## Members that do not exist under UXP

- `[]` — the index accessor on 207 collections. Use `item(index)`.
- `XMLElements.itemByName()`

## Further notes

- [ScriptArg](https://www.indesignjs.de/indesignapi/indesign-server/ScriptArg.md): Not reachable in UXP — app.scriptArgs is undefined there. Read arguments from require("uxp").script.args.
- [XMLElements](https://www.indesignjs.de/indesignapi/indesign-server/XMLElements.md): itemByName() does not work under UXP. Use evaluateXPathExpression() on the parent XMLElement instead.
- `addEventListener()` on 366 objects: The handler can also be the path of a .jsx file as a string — that script runs as ExtendScript when the event fires.
- `Application.scriptArgs`: Undefined in UXP. Read arguments from require("uxp").script.args — an array of strings; InDesign Server passes them as "name=value".
- `Application.doScript()`: A called UXP script receives withArguments as strings in require("uxp").script.args; an ExtendScript receives them as arguments with their types. doScript() returns what a UXP script passes to script.setResult() — its last expression is ignored.
- `EventListeners.add()`: The handler can also be the path of a .jsx file as a string — that script runs as ExtendScript when the event fires.

## Adobe’s documentation

- [UXP](https://developer.adobe.com/uxp/) — the platform: modules, storage, network, UI
- [InDesign UXP](https://developer.adobe.com/indesign/uxp/) — scripts and plugins in InDesign
- [Migrating from ExtendScript](https://developer.adobe.com/indesign/uxp/resources/migration-guides/extendscript/)
- [Passing arguments](https://developer.adobe.com/indesign/uxp/scripts/tutorials/arguments/) and [script result](https://developer.adobe.com/indesign/uxp/scripts/tutorials/script-result/) — `script.args`, `script.setResult()`
