添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Jan 29, 2024 Jan 29, 2024

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/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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/

... 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/
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...

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