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

creating a table in indesign using javascript

New Here ,
Aug 11, 2016 Aug 11, 2016

Hi all,

One of the first days I am using javascript and indesign together. I retrieved information from an xml file, am able to make a textframe and fill it with text with the following code:

var myDocument = app.documents.add();

var myTextFrame = myDocument.pages.item(0).textFrames.add();

myTextFrame.geometricBounds = ["6p", "6p", "10p", "10p"];

myTextFrame.contents = "Test message";

But I can't seem to figure out how to create a table..

Can someone help me please? I just need a table with like 3 rows and 3 columns. I guess it should be very simple and much like adding the textframe but I just can't figure it out..

Thanks in advance

TOPICS
Scripting
3.5K
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

correct answers 1 Correct answer

LEGEND , Aug 11, 2016 Aug 11, 2016

Try:

var myDocument = app.documents.add();

var myTextFrame = myDocument.pages.item(0).textFrames.add({geometricBounds:["6p", "6p", "10p", "10p"]});

var myTable = myTextFrame.insertionPoints[0].tables.add({columnCount:3,bodyRowCount:3}); 

… To be completed! 

Translate
LEGEND ,
Aug 11, 2016 Aug 11, 2016

Try:

var myDocument = app.documents.add();

var myTextFrame = myDocument.pages.item(0).textFrames.add({geometricBounds:["6p", "6p", "10p", "10p"]});

var myTable = myTextFrame.insertionPoints[0].tables.add({columnCount:3,bodyRowCount:3}); 

… To be completed! 

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
Mentor ,
Aug 11, 2016 Aug 11, 2016

Hi

myTable = myTextFrame.insertionPoints[-1].tables.add();

myTable.columnCount = 5;

myTable.bodyRowCount = 5;

myTable.columns[2].width = '10mm';

myTable.rows[1].cells[1].height = '10mm';

HTH

Trevor

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
Mentor ,
Aug 11, 2016 Aug 11, 2016

I didn't see the above answer when I added mine.

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
Mentor ,
Aug 11, 2016 Aug 11, 2016

See Adobe InDesign CS6 (8.0) Object Model JS: Table  for some of the other proprieties you need to set and see also there the cell and row properties.

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 Beginner ,
Dec 20, 2018 Dec 20, 2018
LATEST

If you want to create a table try this

CREATE A TABLE IN INDESIGN USING JAVASCRIPT

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