• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
10

UXP plugin Promises are forever pending

New Here ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

I'm writing a plugin for indesign.
I want to read the name from the active document.
This is my code in a helper file:
```

const { ExportFormat, app } = require("indesign");
const {File} = require('fs');
class exportUtils {

async exportToEpub() {
try {
let doc = app.activeDocument;
let fullName = await doc.fullName;
 
console.log(fullName); // Directly log the fullName
 
let epubFileName = fullName.toString().replace(/\.[^\.]+$/, ".epub");
doc.exportFile(ExportFormat.FIXED_LAYOUT_EPUB, new File(epubFileName), false);
} catch (error) {
console.error(error);
}
};
}
```
The problem is fullName is a Promise and it never resolves.
I expected it to be a File object according to the api reference here: https://developer.adobe.com/indesign/dom/api/d/Document/
TOPICS
Scripting , UXP Scripting

Views

286

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jan 29, 2024 Jan 29, 2024

UXP tries to mimic the full browser experience including all security circus.
See your promise details, maybe something about PromiseState "rejected" and PromiseResult Error: Could not find an entry … ?
This could be about missing permission requests in your manifest.
If your await works in an UXP Script, the difference is described here: https://developer.adobe.com/indesign/uxp/resources/fundamentals/manifest/
More details for plugins:
https://developer.adobe.com/indesign/uxp/plugins/concepts/manifest/

...

Votes

Translate

Translate
Guide ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

UXP tries to mimic the full browser experience including all security circus.
See your promise details, maybe something about PromiseState "rejected" and PromiseResult Error: Could not find an entry … ?
This could be about missing permission requests in your manifest.
If your await works in an UXP Script, the difference is described here: https://developer.adobe.com/indesign/uxp/resources/fundamentals/manifest/
More details for plugins:
https://developer.adobe.com/indesign/uxp/plugins/concepts/manifest/
Basically you need:
"requiredPermissions": {
"localFileSystem": "fullAccess"
}
General info on Files the UXP way:
https://developer.adobe.com/indesign/uxp/reference/uxp-api/reference-js/Modules/uxp/Persistent%20Fil...

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

LATEST

Thank you, this helped me!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines