18 Replies Latest reply on Apr 11, 2011 9:05 AM by Peter Kahrel

    Text frame creation- urgent

    karthikb1987 Level 1

      Hi

      I use indesign CS4 javascript methology.

      I want to create a text frame which will consist of

      1. an image

      2. Different text in each line

      Please find the sample textframe below.

      Some text in the textframe needs to be updated in the furure. So some way or other i need to find the text.

      Sample.JPG

      Please help me to create the textframe.

       

      Thanks

      Karthik



        • 1. Re: Text frame creation- urgent
          John Hawkinson Level 5

          What's your actual question? "How do I create a textFrame"?

          app.activeDocument.pages[0].textFrames.add().

           

          Perhaps you should read "Creating a text frame" on p.71 of the scripting guide? (err, for cs5; you can find it for cs4)

          • 2. Re: Text frame creation- urgent
            Green4ever Level 3

            It seems you are trying to place a inline image and also you want add some text after that.


            First create a text frame and place the figure using place command.

             

            TextFrame.place(<FiletoPlace>);
            

             

            Then add the text you want.

             

            Give a Try....

            • 3. Re: Text frame creation- urgent
              karthikb1987 Level 1

              Hi ,

              Thanks for your reply.

              I can create a textframe . but how to create a textframe which consist of inline image and inline text which needs to be modified for future updation

               

              Thanks

              Karthik

              • 4. Re: Text frame creation- urgent
                karthikb1987 Level 1

                I can create a textframe . but how to create a textframe which consist  of inline image and inline text which needs to be modified for future  updation.

                 

                the text inside that should be tagged or labelled for future updation

                • 5. Re: Text frame creation- urgent
                  Peter Kahrel Adobe Community Professional & MVP

                  You can create a text frame, you said, and Green4ever showed you how to place an image in it.

                   

                  var tframe = app.documents[0].pages[0].textFrames.add ();

                  tframe.geometricBounds = [0,0,"150mm","150mm"];

                  // place() returns an array, the image is therefore item [0]

                  // the inline is not the image, but it's container (i.e. its parent)

                  var inline = tf.insertionPoints[0].place (myFile)[0].parent;

                  inline.anchoredObjectSettings.anchoredPosition = AnchorPosition.aboveLine;

                  tframe.insertionPoints[-1].contents = "\rSample text\rMore sample text";

                  tframe.fit (FitOptions.frameToContent);

                   

                   

                  Peter

                  1 person found this helpful
                  • 6. Re: Text frame creation- urgent
                    karthikb1987 Level 1

                    HI Peter Kahrel,

                    Thanks for your reply. Everything seems to be ok but i need to modicfy the given text for future updation. Can the text placed be referenced later. Is there any possiblilty with this approach.

                    • 7. Re: Text frame creation- urgent
                      John Hawkinson Level 5

                      Yes.

                       

                      (Was there a question lurking in there? If so, please try writing with about four times as many details. Your English is difficult to understand. Also, give examples.)

                      • 8. Re: Text frame creation- urgent
                        karthikb1987 Level 1

                        Hi,

                        I want to create a textframe which consist of inline images and texts. I have given a sample in the above post. The solution given by peter exactly works for creating a textframe of the same kind.

                        But my question is how to indvidually identify the text in a textframe for future modicfication.

                         

                        Thanks Karthik

                        • 9. Re: Text frame creation- urgent
                          John Hawkinson Level 5

                          Unfortunately you are still not making much sense.

                           

                          You need to do a better job asking questions if you would like to get good answers!

                           

                          Please give examples of what you want.

                           

                           

                           

                          If you follow Peter's example, the tframe variable contains a reference to your textFrame. You can save it in the tframe variable, or save it in an array or an Object for reference later. That should be all you need.

                           

                          What do you mean by "identify"?

                           

                          You can also save the textFrame's id (tframe.id), or you can give it a script label.

                          You also look at its contents.

                           

                          You can later retrieve a specific textFrame by it's id with app.activeDocument.textFrames.itemByID().

                          Or you can retrieve based on some other attribute with a loop:

                           

                          var i;
                          for (i=0; i<app.activeDocument.textFrames.length; i++) {
                            if (app.activeDocument.textFrames[i].contents.match(/answers/)) {
                              // do something
                            }
                          }
                          

                           

                           

                          etc.

                          1 person found this helpful
                          • 10. Re: Text frame creation- urgent
                            Peter Kahrel Adobe Community Professional & MVP

                            > I need to modicfy the given text for future updation

                             

                            Do you mean the text in the text frame produced by the script? Then just change the text: it's in a normal, plain, standard, InDesign frame. Click in it, use the Find/Change dialog, etc. etc.

                            Or do you mean that you want to change the text that the script inserts? If that's the case you need to change the script.

                             

                            Peter

                            • 11. Re: Text frame creation- urgent
                              karthikb1987 Level 1

                              Hi Peter,

                              I insert the script the text and the inline image using the indesing script. After filling the textframe with text. Some part of the text needs to be modified later. For that reason i need to lcoate the text. could you please help me on this.

                               

                              Thanks

                              Karthik

                              • 12. Re: Text frame creation- urgent
                                Green4ever Level 3

                                It would be easier if you show some examples of the text you are going to insert inside the frame.

                                 

                                You said,

                                Some part of the text needs to be modified later.

                                For this you can apply specific character style or you can apply a different color to that text for future identification. But one thing, How you will change your text? I mean on what basis you are going to change those texts?

                                 

                                If you are clear about the above questions, then yes you can change the texts by script.

                                 

                                -------

                                Green4ever

                                • 13. Re: Text frame creation- urgent
                                  karthikb1987 Level 1

                                  Hi,

                                  Please find the example below.

                                  SAmple.JPG

                                  In this example, i have a single textframe with inline images and text.

                                  After placing these contents through script, i need to modify one of the sample text.

                                  For example, if i need to modify "Sample text 17" to "Hello" then how to modify it.

                                  Please let me know if  i am unlear.

                                   

                                  Thanks,

                                  Karthik

                                  • 14. Re: Text frame creation- urgent
                                    Green4ever Level 3

                                    Well, then you can do a find and replace using the following command,

                                     

                                    E.g.

                                         app.findTextPreferences = NothingEnum.nothing;
                                         app.changeTextPreferences = NothingEnum.nothing;
                                         app.findTextPreferences.findWhat = "Sample text 17";
                                         app.changeTextPreferences.changeTo = "Hello";
                                         app.activeDocument.changeText();
                                    

                                     

                                     

                                    By the same way you can do this for your exact requirement.

                                    • 15. Re: Text frame creation- urgent
                                      Peter Kahrel Adobe Community Professional & MVP

                                      >  if i need to modify "Sample text 17" to "Hello" then how to modify it.

                                       

                                      This is elementary InDesign: select the text "Sample text 17"; press Del; type "Hello". Done.

                                       

                                      Peter

                                      • 16. Re: Text frame creation- urgent
                                        karthikb1987 Level 1

                                        Hi,

                                        Thanks for your reply, the solution really works.

                                        One demand i have is,  i need apply a specific font for the particular text.

                                        For example after replacinf the text "Sample text 17"  to "hello". i need to apply "Arial" font to only hello.

                                        could you please help me in this.

                                         

                                        Thanks

                                        Karthik

                                        • 17. Re: Text frame creation- urgent
                                          csm_phil Level 4

                                          Hi,

                                           

                                          You can you this:

                                           

                                           

                                          app.findTextPreferences = NothingEnum.nothing;
                                          app.changeTextPreferences = NothingEnum.nothing;
                                          app.findTextPreferences.findWhat = "thie is the sample";
                                          app.changeTextPreferences.appliedFont = app.fonts.itemByName("Arial");

                                          //if you want change the point size use the below line

                                          //app.changeTextPreferences.pointSize = "18pt"
                                          app.changeTextPreferences.changeTo = "Hello";
                                          app.activeDocument.changeText();

                                           

                                          thx

                                          csm_phil

                                          • 18. Re: Text frame creation- urgent
                                            Peter Kahrel Adobe Community Professional & MVP

                                            Karthik -- Maybe you should have a look at an introductory text on InDesign.

                                             

                                            Peter