Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ The second way is to log data in the application's log. You can use the followin
```

### __Complete Sample script__
A sample script can be found under [Example](Example/), where the main script is sample.jsx, and the rest are supporting scripts.
Sample capability bundles live under [SampleScripts](SampleScripts/). For a **minimal template** (logging, working folder, error handling, uploads), start from [customCapabilityTemplate](SampleScripts/ExtendScript/customCapabilityTemplate/) and edit `capabilityLogic.jsx`.
- This script has the functionality to create `idml` from an InDesign document.
- This script can be treated as a baseline script that handles input and output.

Expand Down
Binary file added SampleScripts/.DS_Store
Binary file not shown.
Binary file not shown.
56 changes: 56 additions & 0 deletions SampleScripts/ExtendScript/customCapabilityTemplate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Custom Capability Template

Minimal ExtendScript template for **InDesign Server** capabilities: add logic in `capabilityLogic.jsx` and keep standard parameter handling, logging, timings, and errors.

## InDesign Server scripting

Server runs headless—**do not rely on `app.activeDocument` or creating documents without a file path**. Open the job document with `app.open(File(...))` using a path relative to `workingFolder` (this template does that via `params.targetDocument`).

For the object model (`Application`, `Document`, `app.open`, etc.), see the ExtendScript API reference, e.g. [InDesign Server 14 Application / object model](https://www.indesignjs.de/extendscriptAPI/indesign-server14/#Application.html).

## Quick start

1. **Required input:** `params.targetDocument` — relative path to the `.indd` under `workingFolder`. The template opens it, relinks, collects warnings, then runs your logic.

2. **Implement your logic** in `capabilityLogic.jsx` inside `CAPABILITY.run`:
- `document` — opened document
- `parameters` — `params` from the job
- `allParameters` — full job input (`workingFolder`, `params`, …)
- `returnVal` — populate for `processedData`

3. **Run** the capability with JSON containing `workingFolder` and `params`.

## Files

| File | Purpose |
|------|--------|
| `sample.jsx` | Entry: open document from `targetDocument`, then `CAPABILITY.run`. |
| `capabilityLogic.jsx` | **Edit here** — your capability inside `CAPABILITY.run()`. |
| `errors.jsx`, `json2.jsx`, `utils.jsx` | Shared helpers (same pattern as other samples). |
| `manifest.json` | Capability manifest. |

## Example: save to output path

In `capabilityLogic.jsx`:

```javascript
var outputPath = UTILS.GetStringFromObject(parameters, 'outputPath')
outputPath = UTILS.GetFullPath(outputPath)
document.save(File(outputPath))
UTILS.AddAssetToBeUploaded(UTILS.GetRelativeReturnPath(outputPath))
returnVal.outputPath = outputPath
```

## Input shape

```json
{
"workingFolder": "/path/to/working/folder",
"params": {
"targetDocument": "doc.indd",
"outputPath": "out/result.indd"
}
}
```

If your capability only produces new files (no input `.indd`), you still need a document open on Server—use a small template `.indd` as `targetDocument` or extend the template to open a specific starter file your job provides.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2026 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
**************************************************************************/

// capabilityLogic.jsx
// Add your capability logic here. This is the only file you need to edit.
// InDesign Server: the document is always opened from params.targetDocument before this runs.
//
// - document: InDesign document (already open)
// - parameters: allParameters.params (or allParameters.input.params)
// - allParameters: full job input (workingFolder, params, etc.)
// - returnVal: object to fill with your result; will be returned as processedData

var CAPABILITY = {}

/**
* Implement your capability here.
* Add properties to returnVal to return data (e.g. returnVal.outputPath = path).
* Use UTILS.GetStringFromObject(parameters, 'key'), UTILS.GetFullPath(path), etc.
* Use UTILS.AddAssetToBeUploaded(path) to upload output files.
*/
CAPABILITY.run = function (document, parameters, allParameters, returnVal) {
// ========== ADD YOUR CAPABILITY LOGIC BELOW ==========

UTILS.Log('Custom capability: no logic implemented yet.')

// Example (uncomment and adjust for your case):
var outputPath = UTILS.GetStringFromObject(parameters, 'outputPath')
outputPath = UTILS.GetFullPath(outputPath)
UTILS.Log('outputPathYayyyyy: ' + outputPath)
document.open(File(outputPath + "/input.inddc"))
UTILS.Log('document openedYayyyyy')
UTILS.AddAssetToBeUploaded(UTILS.GetRelativeReturnPath(outputPath))
returnVal.outputPath = outputPath

// ========== ADD YOUR CAPABILITY LOGIC ABOVE ==========
}
167 changes: 167 additions & 0 deletions SampleScripts/ExtendScript/customCapabilityTemplate/errors.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2025 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
**************************************************************************/
// errors.jsx

// Error constants are defined here.
/* This document list all the error which are possible from the scripts. The error object is built such that it has an error code and some error strings.
The error strings are constructed in a way such that the first string is default and a string literal. It is to be returned anyhow. The subsequent strings can be
strings having '^1' as placeholder replacement string. This replacement string can be replaced with relevant information. Based on the information
available the final error message can be created.
*/
/* eslint-disable no-unused-vars */

var ErrorReplacementString = '^1'

var Errors = {
// Errors during processing: 1001-1999
InternalScriptError: {
errorCode: 'internal_error',
errorStrings: [
'Internal script error. This should not had happened.'
]
},
ProcessingErrorOccurred: {
errorCode: 'internal_error',
errorStrings: [
'Internal error: Error during processing.'
]
},
PDFPresetNotSet: {
errorCode: 'capability_error',
errorStrings: [
'Capability error: No PDF Preset could be set.'
]
},
OutputDirError: {
errorCode: 'internal_error',
errorStrings: [
'Internal error: Unable to create specified output directory.'
]
},
RelinkError: {
errorCode: 'capability_error',
errorStrings: [
'Capability error: Unable to relink.',
'Relink failed for ^1.'
]
},
PlaceError: {
errorCode: 'capability_error',
errorStrings: [
'Capability error: Unable to place.',
'Place failed for ^1.'
]
},

// Errors in input: 2001-2999
ArrayExpected: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Expected array ',
'for property ^1.'
]
},
ParsingBoolError: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Expected boolean ',
'^1 is the provided value ',
'for property ^1.'
]
},
ParsingIntError: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Expected integer ',
'^1 is the provided value ',
'for property ^1.'
]
},
ParsingFloatError: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Expected number ',
'^1 is the provided value ',
'for property ^1.'
]
},
ParsingStringError: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Expected string ',
'^1 is the provided value ',
'for property ^1.'
]
},
OutOfBound: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Incorrect range provided. ',
'Culprit Value is ^1.'
]
},
MissingKey: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Key not found in object. ',
'Missing key is ^1.'
]
},
EnumError: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: No matching enum value found. ',
'^1 is the provided value',
'for property ^1.'
]
},
MissingParams: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Either the \'params\' is not found in the request or it is not in the correct format.'
]
},
ObjectExpected: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Expected object ',
'for property ^1.'
]
},
AtLeastOneInternalParamShouldBePresent: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: At least one of the parameters should be present. ',
'Missing parameters are ^1'
]
},

// Errors coming from IDS and sent under ProcessingErrorOccurred. These are specific errors which need string change while returning to the user.
CannotOpenFileError: {
errorCode: 'capability_error', // kCannotOpenFileError
errorStrings: [
'Capability error: Cannot open file.'
]
},
InCorrectRelativePath: {
errorCode: 'parameter_error',
errorStrings: [
'Parameter error: Incorrect relative path.',
'^1 is the provided path.'
]
}
}
Loading