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

How to correctly create an HTML object in an InDesign layout with UXP?

New Here ,
Oct 30, 2023 Oct 30, 2023

Copy link to clipboard

Copied

Basic example:

 

// currentPage = the current page InDesign

let htmlContent = '<p>Hello</p>';

let newRectangle = currentPage.rectangles.add();
let htmlItem = newRectangle.htmlItems.add( { htmlContent } );
 

This code works partially.
A block is created in the InDesign layout and the HTML code is correctly assigned.

 

But it doesn't work in the HTML preview or in a digital publication.

 

If the HTML block is created manually in the InDesign interface, there is an additional step which "validates" the specificity of the HTML block.

 

I've tried browsing javascript objects created manually or in JS UXP, and I can't detect any difference.
But there is a difference that prevents it from working properly.

 

Does anyone have any information on this subject?

 

Many thanks for your help!

TOPICS
Publish online , UXP Scripting

Views

62

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
New Here ,
Oct 30, 2023 Oct 30, 2023

Copy link to clipboard

Copied

LATEST

I found a (not very clean) workaround.


I manually created an Html block in a hidden layer.
I use this Html block as the master element and duplicate and customize it with UXP JS as many times as necessary.
Ideally, I'd like to be able to create an Html block with JS UXP from scratch.

 

Thanks for your insights!

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