Copy link to clipboard
Copied
Hello everybody!
I have a file (an unfinished *.indt template) and I want to place it inside the plugin file structure. I want to develop a command that will open this file, make some corrections to a set of text variables, and then the user will save it as a new *.indd .
Is it possible to do this? I still don't understand what path it will have, being located in the plugin, and how to get to it...
It is not desirable that this file be edited by the end user, so I would like to hide this file inside.
const entry = await localFileSystem.getEntry("../ugj2023.indt");I tried to play with something like this, but there is no reaction.
The solution has just been found. If you need to open the InDesign template file hidden in the plugin assembly, this is solved with a couple of lines:
const { app } = require("indesign");
const fs = require("uxp").storage.localFileSystem;
async function createNewDocFromTemplate() {
// Plugin Folder
const folder = await fs.getPluginFolder();
// Entry (file) "ugj2023.indt" in the folder "ugj"
const entry = await folder.getEntry("ugj/ugj2023.indt");
app.open(entry); /// ugj2...
Copy link to clipboard
Copied
Even if you could store indt file in a binary form - how do you plan on updating your script - when it is running? Will JS allow you to overwrite itself during execution?
I'm not JS expert so just speculating.
Copy link to clipboard
Copied
The plugin (working version) will not be changed in any way programmatically during operation. The idea is that there is no need to place the template file on some computer in a previously unknown location, keep the path to it, and check each time whether it still exists at this path and whether its version corresponds to the version of the plugin. It's easier to store it inside the plugin's file structure.
If a *.indt file is opened, InDesign offers to save it already as a working *.indd file. And before that, I can set some clarifying parameters, for example through a dialog. The *.indt file is not planned to be "returned" to the plugin after making changes.
The problem is in the vaguely formulated description of the "fs", and "uxp" modules. There are apparently few examples.
Copy link to clipboard
Copied
The solution has just been found. If you need to open the InDesign template file hidden in the plugin assembly, this is solved with a couple of lines:
const { app } = require("indesign");
const fs = require("uxp").storage.localFileSystem;
async function createNewDocFromTemplate() {
// Plugin Folder
const folder = await fs.getPluginFolder();
// Entry (file) "ugj2023.indt" in the folder "ugj"
const entry = await folder.getEntry("ugj/ugj2023.indt");
app.open(entry); /// ugj2023.indt is now active document...
}
module.exports = { createNewDocFromTemplate };It is very difficult to use the provided information about UXP, unfortunately...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now