5 Replies Latest reply on Feb 8, 2015 7:33 AM by Ronald63

    Recompose issue

    Ronald63 Level 4

      Hi,

       

      I have a problem with text flowing even using recompose() [CC 2014]

      anchored_frame_bad.jpg

      After shortcut Command-Option-/ for "Recompose All Stories" ...

       

      anchored_frame_good.jpg

      
      
      old_VOrigin = app.documents[0].viewPreferences.verticalMeasurementUnits;
      old_HOrigin = app.documents[0].viewPreferences.horizontalMeasurementUnits;  
      app.documents[0].viewPreferences.horizontalMeasurementUnits =  
      app.documents[0].viewPreferences.verticalMeasurementUnits =  
      MeasurementUnits.POINTS;  
      app.findTextPreferences = null;  
      app.findTextPreferences.appliedParagraphStyle = "CRITIQUE_tmp"; 
      var myFound = app.documents[0].findText();
      var myLen = myFound.length;
      while (myLen--) {    
      myPara = myFound[myLen];
      myStory=myPara.parent;
      myText= myPara.texts[0].contents;
      myText=myText.substring(0,myText.length-1);
      myPara.texts[0].contents="";
      myPara.insertionPoints[0].contents='\r'
      myAnchorFrame = myPara.insertionPoints[0].textFrames.add({geometricBounds:[0,0,10,230],appliedObjectStyle: app.documents[0].objectStyles.item("CRITIQUE")}); // geometricBounds: [50,50,30,30]
      myAnchorFrame.parentStory.texts.item(0).contents =myText;
      myAnchorFrame.parent.paragraphs[0].appliedParagraphStyle = "CRITIQUE_para";
      }
      myStory.recompose();
      app.documents[0].viewPreferences.horizontalMeasurementUnits = old_HOrigin;  
      app.documents[0].viewPreferences.verticalMeasurementUnits = old_VOrigin;  
      app.findTextPreferences = null; 
      
      

       

      Any idea ?

       

      Regards

      Ronald

        • 1. Re: Recompose issue
          [Jongware] Most Valuable Participant

          I see the differences between the two images, but what exactly is the error and what is the good one?

          • 2. Re: Recompose issue
            Laubender Adobe Community Professional & MVP

            @Ronald – I guess, you mean the method recompose() vs. doing it with the UI shortcut is not the same thing.

            And after running your code the UI shortcut would do the thing yu want to accomplish.

             

            I can see the difference here. And it might be, that the anchoredObjectSettings are not honored in your first screen shot.

            Can you give us more details of the used settings for anchored objects here?

            Namely the options that the applied object style should use, but obviously does not use.

             

            Instead of recomposing the story that holds the anchored text frames, I would test recomposing the anchored text frames themselves.

             

            myAnchorTextFrame.recompose();
            

             

            Uwe

            • 3. Re: Recompose issue
              Ronald63 Level 4

              @Jongware: The problem is the position of the anchored text block (see first image). I fix it by the UI shortcut Command-Option-/  (see second image)


              @Laubender : settings the applied object for anchored objects

              Options_de_style_d_objet.jpg

              I look for recomposing anchored text frames ..


              Thanks

              • 4. Re: Recompose issue
                Peter Kahrel Adobe Community Professional & MVP

                Ronald,

                 

                It's true that recompose() often doesn't work in a script. What I found to work most of the time is if you give a text frame a good kick in the but:

                 

                gb = frame.geometricBounds;
                // Change the frame's height a bit
                frame.geometricBounds = [gb[0], gb[1], gb[2]+0.5, gb[3]];
                // Restore the frame's bounds
                frame.geometricBounds = gb;
                

                 

                Peter

                • 5. Re: Recompose issue
                  Ronald63 Level 4

                  It works perfectly
                  Thanks


                  old_VOrigin = app.documents[0].viewPreferences.verticalMeasurementUnits;
                  old_HOrigin = app.documents[0].viewPreferences.horizontalMeasurementUnits;  
                  app.documents[0].viewPreferences.horizontalMeasurementUnits =  
                  app.documents[0].viewPreferences.verticalMeasurementUnits =  
                  MeasurementUnits.POINTS;  
                  
                  app.findTextPreferences = null;  
                  app.findTextPreferences.appliedParagraphStyle = "CRITIQUE";
                  
                  var myFound = app.documents[0].findText();
                  var myLen = myFound.length;
                  
                  while (myLen--) {
                      myPara = myFound[myLen];// Get paragraph
                      myText = myPara.texts[0].contents;// Get paragraph's contents
                      myText = myText.substring(0,myText.length-1);// Get paragraph's contents without CR
                      if (myText.length >1) { // Test contents
                          myPara.texts[0].contents=""; // Remove contents
                          myPara.insertionPoints[0].contents='\r'; // Insert CR
                          myAnchorFrame = myPara.insertionPoints[0].textFrames.add({geometricBounds:[0,0,10,230],appliedObjectStyle: app.documents[0].objectStyles.item("CRITIQUE")}); // geometricBounds: [50,50,30,30]
                          myAnchorFrame.parentStory.texts.item(0).contents =myText; // Put text in anchored frame
                          myAnchorFrame.parent.paragraphs[0].appliedParagraphStyle = "CRITIQUE"; // Apply paragraph style
                          // REDRAWING ANCHORED BOX
                          myBounds = myAnchorFrame.geometricBounds; // get the frame's bounds
                          myAnchorFrame.geometricBounds = [myBounds[0], myBounds[1], myBounds[2]+0.1, myBounds[3]]; // change the frame's height a bit 
                          myAnchorFrame.geometricBounds = myBounds; // restore the frame's bounds 
                      }
                  }
                  app.documents[0].viewPreferences.horizontalMeasurementUnits = old_HOrigin;  
                  app.documents[0].viewPreferences.verticalMeasurementUnits = old_VOrigin;  
                  app.findTextPreferences = null;