Skip to main content
Participant
June 5, 2024
Question

Placing a graphic from the local file system in Indesign UXPScript

  • June 5, 2024
  • 4 replies
  • 390 views

I am surprised this is so hard. No recipe in the docs seems to cover this. Here's what I am trying to do:

 

  const imageFrame = targetPage.rectangles.add();
  const imageFile = fs.readFileSync(`${DATA_FOLDER_PATH}/${imageFileName}`);
  const placedImage = imageFrame.place(imageFile);
  imageFrame.geometricBounds = [yStart, xStart, yEnd, xEnd];

 

The error alert says that the first argument to place isn't being supplied. This isn't quite right, of course. In the console I can see that the file is being located in the file system. `imageFile` is an `ArrayBuffer` so it's not that. How do I pass the File into `place`?

 

Thanks in advance for any help.

This topic has been closed for replies.

4 replies

Peter Kahrel
Community Expert
Community Expert
June 5, 2024
Robert at ID-Tasker
Legend
June 5, 2024

@B3NJ_M_N

 

I'm not JS expert, but why do you have quotes around:

 

const imageFile = fs.readFileSync(`${DATA_FOLDER_PATH}/${imageFileName}`);

 

Can you build this string as a variable and then pass this variable? So you can use alert() or something for debugging? 

 

Community Expert
June 5, 2024

Hi @B3NJ_M_N ,

I would test method place() with a simple JPEG file.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

leo.r
Community Expert
Community Expert
June 5, 2024

I don't have an answer for this, just wanted to mention that for UXP questions you may also want to join these forums:

 

https://forums.creativeclouddeveloper.com/