2 Replies Latest reply on Mar 5, 2014 8:03 AM by Laubender

    How to copy the contents in the frame with formatting?

    Gejaraja Level 1

      Hello,

       

      I'd like to have the script concept to copy the contents with formatting (italic, bold, etc.) into the separate frame, please advise.

       

      Thanks,

       

      Praveen

        • 1. Re: How to copy the contents in the frame with formatting?
          Jump_Over Level 5

          Hi,

           

          Text duplicate (to: LocationOptions[, reference: varies])

          Duplicates the text in the specified location keeping its properties.

           

          Jarek

          • 2. Re: How to copy the contents in the frame with formatting?
            Laubender Adobe Community Professional & MVP

            @Praveen – as Jarek already said you have to work with the Text Object (which is a super class for formatted text like  Character, Paragraph and also the InsertionPoint class amongst others) and use the duplicate() method.

             

            One example: we have two text frames with formatted text on page one of a document.

            We want to duplicate the first two characters of one of the text frames after the third character of the other.

             

            Note 1: the end of character 3 of text frame 2 is the fourth insertionPoint counted.

            Its index is 3 (counting begins with 0).

             

            Note 2: An empty text frame has no characters but there is one single insertionPoint with index 0.

            So it's always good practice to target an insertionPoint.

             

            var myDoc = app.documents[0];
            
            var sourceTextFrame = myDoc.pages[0].textFrames[0];
            var targetTextFrame = myDoc.pages[0].textFrames[1];
            
            sourceTextFrame.texts[0].characters.itemByRange(0,1).duplicate
                (
                LocationOptions.AFTER,
                targetTextFrame.insertionPoints[3]
                );
            

             

            Uwe