4 Replies Latest reply on Mar 25, 2013 8:54 PM by booyajamo

    [JS] autoflow in 2 columns/textframes




      I read through this post, http://forums.adobe.com/message/2142563#2142563, to get myself started, but still can't manage the autoflow properly. The main trouble I have is that the catalogue's layout has two columns, which are set up as separate text boxes, linked together. So I need the autoflow to add a new page, two new text boxes, link them together, and link the first one to the second text box on the previous page; in additiong to if the second one still overflows, repeat the process.


      This is my function, which is, of course, broken. I'm stull unsure as to how to refer to the last page in the document in the while statement (I've tried .pages.lastItem(), but get an object does not support method overflow error with that.

      function flow (myDocument) {

      while (myDocument.pages[1].textFrames[1].overflows) {
      var myTextFrame1 = myDocument.pages.add().textFrames.add;
      myTextFrame1.geometricBounds = [15, 14, 198, 62]
      var myTextFrame2 = myDocument.pages.lastItem().textFrames.add;
      myTextFrame2.geometricBounds = [15, 66, 198, 132]
      myTextFrame1.nextTextFrame = myTextFrame2
      myTextFrame1.previousTextFrame = myDocument.pages[1].textFrames[1]; }

      My question is how do I refer to both the pages and textboxes in their respective arrays dynamically, so I can have the overflow check on the last text frame of the last page? As it stands the script will run, but adds pages forever, so I also assume my linking of the textframes is not working properly either, because the textframe in the while statement is always overflowing.


      I'll keep trying at it and report back if I have a breakthrough. Otherwise I would really appreciate some guidance.


      Thanks in advance!

        • 1. Re: [JS] autoflow in 2 columns/textframes
          Bob Stucky Adobe Employee

          Before heading down this path...


          Have you tried setting up your pages with multiple columns and then using


          page.placeXML( using, placepoint, autoflow )


          In a previous life, I used that method to auto-flow large, facing page, multi-column catalogs.


          I've also used that method to place 100+ page documents of xhtml, that was then correctly styled using XmlRules after the place.





          1 person found this helpful
          • 2. Re: [JS] autoflow in 2 columns/textframes
            nickbarreto Level 1

            Hi Bob,


            I could certainly consider it. I have not used placeXML before, and I don't know if it behaves differently from import XML. At the moment I am importing xml into a template tagged with corresponding elements, which means the catalogue is autogenerated. Would placeXML work in the same manner, by replacing and cloning repeating elements as necessary, while ignoring whitespace to preseve the layout? If so, I'll look into that approach, certainly.


            Surely if I am styling after the fact with XMLRules that means that I'll need a new script/new XMLRules each time I have a new layout? The benefit of using import XML here is that as long as the element tags are still in the same order, I can change/create a completely new layout that will still work with the script.

            • 3. Re: [JS] autoflow in 2 columns/textframes
              Bob Stucky Adobe Employee

              Depends on exactly what you're doing.


              Your post talked about flowing xml through a 2 column document, yes, it will do that.


              If you are specifically using anchored frames and such inside those auto-flowed frame, you'll need to run an XMLRule to properly handle the frame.


              If your XML contains tables, it will render tables if the XML is correctly designed. For example, it will render an html table if you remove the <tr> and <th> tags from the html and add hints, and there are other table formats it will correctly render.



              • 4. Re: [JS] autoflow in 2 columns/textframes
                booyajamo Level 1

                Hi Bob,


                I have begun my first script to auto format a catalog from a well structured XML file. I found your placeXML option extremely useful. My catalog is only about 50 pages and the specific chapter I've been testing my script on is only 4 pages. It's a catalog of products with info like: name, product#, description, etc. here's what I've setup so far


                1) create doc

                2) define paragraph styles

                3) map styles to XML tags

                4) import XML

                5) place XML (using the example you note above)


                Have you had issues with placing XML with mapped styles? My INDD crashes every time on the place. If I define styles and only give each style a name without setting any other property it won't crash. Any thoughts on why applying paragraph styles when placing XML would cause a "can't reference memory at ..." Error?


                Any insight is greatly appreciated. Thanks!