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

Placing a graphic from the local file system in Indesign UXPScript

New Here ,
Jun 04, 2024 Jun 04, 2024

Copy link to clipboard

Copied

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

Views

182

Translate

Translate

Report

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

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi @B3NJ_M_N ,

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

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

@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? 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

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