Copy link to clipboard
Copied
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
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! ![]()
Copy link to clipboard
Copied
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! ![]()
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I didn't see the above answer when I added mine.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
If you want to create a table try this
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more