9 Replies Latest reply on Jun 11, 2010 6:15 AM by [Jongware]

    [IDCS4][Apply Bold on Text]

    Poo_Del

      Hi All,
      I want to apply bold formatting on text "Poo" & "Test" of page 1 of active document.

       

      Regards,
      Poo

        • 1. Re: [IDCS4][Apply Bold on Text]
          [Jongware] Most Valuable Participant

          That could be done with search-and-replace. You cannot replace per page, but, fortunately, you can do a replace on a single text frame (which is not possible in the User Interface!). You'd have to loop over all text frames on the first page and do the replace on each one.

           

          If you use GREP instead of the regular replace, you don't need to do two replace operations. You can use this GREP "\<(Poo|Test)\>", replacing with Bold formatting only.

          • 2. Re: [IDCS4][Apply Bold on Text]
            Poo_Del Level 1

            I don't want to do it through find and replace. I want for 1st page only. I want it should happen through scripts.

             

            Regards,

            Poo

            • 3. Re: [IDCS4][Apply Bold on Text]
              [Jongware] Most Valuable Participant

              That's ... unusual ... Why?

               

              If you don't want to do a search, how do you want to get to the words? You can loop over all words (in all textframes on that page, etc.) but that's going to be slow. S&R is instantly.

              • 4. Re: [IDCS4][Apply Bold on Text]
                Poo_Del Level 1

                What I am seeing in Adobe forum is people don't want to put straight answer rather than asking many of arguments.

                 

                Regards,

                Poo

                • 5. Re: [IDCS4][Apply Bold on Text]
                  [Jongware] Most Valuable Participant

                  Well, you might. This forum -- the entire InDesign forum -- has been complimented by newbies for its helpfulness on several occasions.

                   

                  You say "I want to do x". Not a question.

                  No context.

                  You don't mention what version of InDesign you are using -- it might be important (searching, for example, has changed significantly from CS2 to CS3).

                  You don't mention what scripting language you want to use.

                  You don't mention why you cannot find this yourself, or what you tried.

                   

                  What were you expecting? Perhaps we can go from there.

                  • 6. Re: [IDCS4][Apply Bold on Text]
                    [Jongware] Most Valuable Participant

                    (Replying to myself:)

                     

                    Ah -- I think I understand. You think my search-and-replace suggestion was something you should do in the UI. No, it wasn't.

                     

                    First, this is the scripting forum, and if someone asks 'how to do x' (in your case, call out to the world 'I want to do x'), it's generally assumed you want to do so by scripting.

                    Second: I said you could use search-and-replace in a way not available in the UI, which implies a script.

                    • 7. Re: [IDCS4][Apply Bold on Text]
                      Poo_Del Level 1

                      Few things if you are thinking that this related to what we are looking for then "NO", we are putting those questions only which are really required. And may be there is a big code but we are not bothering all guys by putting those code.

                       

                      We can easily migrate any language to any language only thing is that the break through we need.

                       

                      Regards,

                      Poo

                      • 8. Re: [IDCS4][Apply Bold on Text]
                        [Jongware] Most Valuable Participant

                        Oh okay. (I think.)

                         

                        Well, let me re-iterate. My suggestion was

                         

                        That could be done with search-and-replace. You cannot replace per page, but, fortunately, you can do a replace on a single text frame (which is not possible in the User Interface!). You'd have to loop over all text frames on the first page and do the replace on each one.

                         

                        and it seems you have no clue at all how to get started (inferred from you not replying my question of what you tried so far). So I wrote the following script for you and made sure it does exactly what you requested --

                         

                        app.findGrepPreferences = null;
                        app.changeGrepPreferences = null;
                        app.findGrepPreferences.findWhat = "\\<(Poo|Test)\\>";
                        app.changeGrepPreferences.fontStyle = "Bold";
                        page = app.activeDocument.pages.item("1");
                        fram = page.textFrames;
                        for (f=0; f<fram.length; f++)
                         fram[f].changeGrep();
                        

                         

                         

                        (From the Scripting Forum "Dos" and "Don'ts": "If you are a novice scripter and show an interest in learning, you will generally find that the help you recieve will be much more positive." -- and it contains many more friendly tips for novice posters ...)

                        • 9. Re: [IDCS4][Apply Bold on Text]
                          [Jongware] Most Valuable Participant

                          On further thinking: my script does not do 'exactly' what you requested -- it will change the words on that page numbered as "1". That's not really "the first page", under every circumstance.

                          This one will only change the words on the first page of your document:

                           

                          app.findGrepPreferences = null;
                          app.changeGrepPreferences = null;
                          app.findGrepPreferences.findWhat = "\\<(Poo|Test)\\>";
                          app.changeGrepPreferences.fontStyle = "Bold";
                          page = app.activeDocument.pages.item(0);
                          fram = page.textFrames;
                          for (f=0; f<fram.length; f++)
                           fram[f].changeGrep();
                          

                           

                           

                          (FYI, the difference was in the 'page' variable. Rather than assigning it "the page named '1'", I now set it to 'the first page', which is indexed as zero in Javascript.)