Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Placing a graphic from the local file system in Indesign UXPScript

New Here ,
Jun 04, 2024 Jun 04, 2024

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.

TOPICS
Scripting
265
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2024 Jun 04, 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/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2024 Jun 04, 2024

Hi @B3NJ_M_N ,

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

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2024 Jun 05, 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? 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2024 Jun 05, 2024
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines