Hi, I am trying to simply modify one of your code samples (how-to-export-a-rendition) to export to different file formats. It seems to be working fine with .png and .pdf, it doesn’t seem to work with .eps and .jpg.
Here’s my sample code to try to export a selected item to .svg. Basically, I am just replacing the file format.
const application = require("application");
const fs = require("uxp").storage.localFileSystem;
async function exportRendition(selection) {
if (selection.items.length > 0) {
const folder = await fs.getFolder();
const file = await folder.createFile("rendition.svg");
const renditions = [{
node: selection.items[0],
outputFile: file,
type: "svg",
scale: 1
}];
application.createRenditions(renditions)
.then(results => {
// create the dialog
let dialog = document.createElement("dialog");
// main container
let container = document.createElement("div");
container.style.minWidth = 400;
container.style.padding = 40;
// add content
let title = document.createElement("h3");
title.style.padding = 20;
title.textContent = `Rendition has been saved at ${file.nativePath}`;
container.appendChild(title);
// close button
let closeButton = document.createElement("button");
closeButton.textContent = "Got it!";
container.appendChild(closeButton);
closeButton.onclick = (e) => {
dialog.close();
}
document.body.appendChild(dialog);
dialog.appendChild(container);
dialog.showModal()
})
.catch(error => {
console.log(error);
})
}
}
module.exports = {
commands: {
exportRendition
}
};
Thanks for your help!