4 Replies Latest reply on Jul 29, 2010 12:27 PM by Muppet Mark-QAl63s

    Graphic insertion

    Muppet Mark-QAl63s Level 4

      Me again Im back trying to work up my catalogue a little further… Sorted my tab adjustment and price re-placement. Now I wish to add an inline graphic to the start of each of my price list text frames. The graphic in question is a simple group item that consists of 1 oval and 1 text frame. I have included picture just to be clear as possible but Im sure your all familiar with what Im trying to do… These were none native objects in my old Quark job (don't know why) but I would like to replace like so…

       

      Picture 1.png

      How Im I best to go about this Im CS2 so I don't think some find & replace is going to work for me. Should I use copy while its selected (it has a baseline shift applied) then paste at the start of each following paragraph or should I be using place which appears to want a file object? to do this? I don't want to be affecting the rest of the text frames contents. Just putting this before the first tab of all the paragraphs. The numbering of the text within this group is not a requirement but a possible bonus…

        • 1. Re: Graphic insertion
          Peter Kahrel Adobe Community Professional & MVP

          Easiest would be to insert a frame at each paragraph's insertionPoint[0]. if you search for whole paragraph beginnings, you can use the loop counter to enter the numbers. I forgot how you search in CS2. Was it something like this:

           

          found = app.activeDocument.search (undefined, undefined, undefined, undefined, {appliedParagraphStyle = "myStyle"});

           

          then something like this:

           

          for (i = 0; i < found.length; i++)

             {

             anchor = found[i].insertionPoints[0].textFrames.add ();

             anchor.appliedObjectStyle = . . .;

             anchor.contents = String (i+1);

             // whatever else

             }

           

          Peter

          • 2. Re: Graphic insertion
            Muppet Mark-QAl63s Level 4

            Peter, this is probably the rough way of doing this kind of thing… Closest to how I would have gone about this in the GUI… but it does work with my test file!!!

             

            docRef = app.activeDocument;
            
            docRef.select(docRef.textFrames[0].paragraphs[1].characters.itemByRange(0,1));
            
            app.copy();
            
            var x = docRef.textFrames[0].paragraphs.length;
            
            for (var i = 2; i < x; i++)
                 {
                 docRef.select(docRef.textFrames[0].paragraphs[i].characters[0]);
                 app.paste();
                 }
            

             

            Targeting my text frames like I did in the previous topic. This should get me by for now…

            • 3. Re: Graphic insertion
              Peter Kahrel Adobe Community Professional & MVP

              If it works, it works!

              • 4. Re: Graphic insertion
                Muppet Mark-QAl63s Level 4

                I try avoid selections when possible. But as this is just for me to run Im OK with the idea, all be it crude. I did dig a little further and found one or two other things that Im going to be needing near future. This took the existing string from my group then used it to calculate the remaining graphics text content. It's a rough draft but functioning OK. I will give it a tidy up now that I've found my target elements…

                 

                docRef = app.activeDocument;
                
                var x = docRef.textFrames[0].paragraphs.length;
                var y = docRef.textFrames[0].paragraphs[1].allPageItems[0].textFrames[0].paragraphs[0].contents;
                
                docRef.select(docRef.textFrames[0].paragraphs[1].characters.itemByRange(0,1));
                
                app.copy();
                
                var j = 1;
                     
                for (var i = 2; i < x; i++)
                     {
                     docRef.select(docRef.textFrames[0].paragraphs[i].characters[0]);
                     app.paste();
                     var k = parseInt(y)+j;
                     k = k.toString();
                     docRef.textFrames[0].paragraphs[i].allPageItems[0].textFrames[0].paragraphs[0].contents = k;
                     j++
                     }