-1

Documentation doesn't help at all,no Table or Grid is specified...(or I cant find it)

I tried to create a grid from inside InDesign and it shows up as TextFrame,but still I dont understand how to manage it.

The tool I need to do takes a file(CSV/JSON) and generates a Table(or whatever is called in Adobe) from it,but the problem is that I can't find anything about Table generation.

  • 1
    See [Table](https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Table.html) in the docs for InDesign ExtendScript API. – RobC May 30 '22 at 13:35
  • @RobC it's not exactly helpful link if he wants to create a new table from a text rather than to modify existed one. I'd advice to look for the method `convertToTable()` of the `Text` object https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Text.html for this purpose – Yuri Khristich May 30 '22 at 22:30
  • Have you tried the suggested solution? Could you provide some feedback? – Yuri Khristich Jun 11 '22 at 16:55
  • Nope,I found a easier way to do what I had to – Riccardo Corsi Jun 16 '22 at 08:21

1 Answers1

0

Basically you can make a table from a selected text with the method convertToTable() this way:

var doc = app.activeDocument;                  // your document
var frame = doc.pages[0].textFrames[0];        // first text frame on first page
frame.texts.everyItem().select();              // select all text inside the frame
var table = app.selection[0].convertToTable(); // convert the selection into a table     

Before:

enter image description here

After:

enter image description here

Reference:

As for the rest... it's need more details about your workflow. JSON and CSV are quite different beasts, it would be different parsing algorithms for each of the formats. Will you copy the contents of the files manually or the script should read all csv or json files from some predefined folder? Or there should be some interface to select a file(s). Or a folder? How it supposed to handle a page size and formatting of the table? Etc...

Yuri Khristich
  • 13,448
  • 2
  • 8
  • 23