5 Replies Latest reply on Jan 3, 2017 2:26 AM by grefel

    Trying to understand document creation using JS

    Jens Troeger Level 1



      I’m currently exploring the InDesign scripting capabilities using the InDesign CS6 Javascript Scripting Guide and the Scripting Tutorial. Are there other documents that you would recommend, besides the example scripts in the SDK?


      After reading through them and looking at the code, I do have a few questions and I hope that the community here can help me clarify them. Assume I’ve created a new document and a master spread following the examples in the Scripting Tutorial, pages 29 through 37.


      1. When I add a number of paragraphs, then each paragraph is terminated by a \r character, correct?
      2. It also seems that adding a large number of paragraphs automatically creates new pages, each of which contains its own TextFrame, correct?
      3. As I populate the document with paragraphs, is there a way to set the style for a paragraph and then add the paragraph, or do I have to add the paragraph first and only then can I modify its style?
      4. As I populate the document with paragraphs, how do I keep track of the last paragraph so that I can keep adding after the last one? It looks like InDesign’s object model of pages and text frames does not offer a plain linear view of the added text? (See page 79 of Javascript Scripting Guide.)
      5. Similarly to 3. and 4. but in the context of the text content of a paragraph:
        1. It looks like paragraph.words[] is the way to access the content of a paragraph?
        2. How do I incrementally add text content to a paragraph and style that content? Add first, then select a number of words, then apply a style; or can I change style, then add words in that style, then change and continue with a default style?
      6. How do I insert a page break?
      7. How do I mark some text as a clickable external URL?
      8. Is it possible to mark up some text (words) and associate a comment or pop-over with them, information that does not belong to the actual content of the document?


      For now that’s all, although I do have a few more questions...