Hi there,
First off. I’m a beginner learning by doing and reading this awesome forum. Not sure if this question is in the right place. I’m working on a plugin and most of what I want to achieve has been accomplished. There’s just one thing that I can’t seem to get right.
I’m trying to figure out how to open a PDF file with basically the “PDFOpenOptions” using UXP. I’ve tried the entry.open way but this results in the PDF being opened with the latest settings. Resulting in wrong aspect ratios and resolutions.
I figured I could use batchPlay to insert the right values but this doesn’t work. I’ve used Alchemist to get the open object. I’ve made a function, but when it gets to the open part everything stops. I probably am doing something wrong.
async function batchOpenCanvas(name,res,width,height,path,id) {
console.log("Are we here?");
const batchPlay = require('photoshop').action.batchPlay;
const result = await batchPlay(
[
{
"_obj": "open",
"as": {
"_obj": "PDFGenericFormat",
"name": name,
"crop": {
"_enum": "cropTo",
"_value": "trimBox"
},
"resolution": {
"_unit": "densityUnit",
"_value": res
},
"mode": {
"_enum": "colorSpace",
"_value": "RGBColor"
},
"depth": 8,
"antiAlias": true,
"width": {
"_unit": "pixelsUnit",
"_value": width
},
"height": {
"_unit": "pixelsUnit",
"_value": height
},
"constrainProportions": true,
"suppressWarnings": true,
"reverse": true,
"selection": {
"_enum": "pdfSelection",
"_value": "page"
},
"pageNumber": 1
},
"null": {
"_path": path,
"_kind": "local"
},
"documentID": id,
"_isCommand": true,
"_options": {
"dialogOptions": "dontDisplay"
}
}
],{
"synchronousExecution": false,
"modalBehavior": "fail"
});
console.log("Did we make it?");
return result;
}
Thanks in advance!