9 Replies Latest reply on Jul 30, 2016 4:55 AM by karthiks94217840

    Formatting Text (cut and paste)

    karthiks94217840 Level 2

      Hi Friends,

       

      I need your help!

       

      I am writing a script that will be find to particular paragraph style for "EXM", that paragraph first line match to text frame width and continue the second line cut and paste to after 3rd line (That style paragraph maximum 2 lines only). I have place the below screenshot for your reference friends. Please suggest all friends.

       

      My text frame width: 340.157 pt

       

      Before run script: Normal text formatting.

       

      2.png

       

      After run script: I need text formatting.

       

      1.png

      Please advice friends. This is possible to script? (very urgent process).

       

      Thanks to Advance

       

       

        • 1. Re: Formatting Text (cut and paste)
          AriEss Level 1

          How about you create two text frames one atop the other. In the top frame start the text from the first line, and all subsequent lines should have a full lines' height in between (via large leading).

           

          In the bottom text frame do the same but start from the second line in the text frame.

          • 2. Re: Formatting Text (cut and paste)
            karthiks94217840 Level 2

            Hi AriEss,

             

            Thanks to your replay!

             

            Sorry for saying i con't understand your answer. Please explain clearly.

             

            **This book full and full same formatting only. That is a big problem.

             

            Please review my above question and screenshot. Help me friends,

             

            Thanks in Advance

            • 3. Re: Formatting Text (cut and paste)
              AriEss Level 1

              I don't understand completely what you're trying to do. Tell me if this is right: You want every second row to switch with the third row.

              So it should go from this:

               

              Line 1

              Line 2

              Line 3

              Line 4

               

              To this:

               

              Line 1

              Line 3

              Line 2

              Line 4

               

              Am I right? But then you mention something about "EXM", what's that? And what about indented formatting that you applied?

              • 4. Re: Formatting Text (cut and paste)
                karthiks94217840 Level 2

                Hi AriEss,

                 

                Thanks to your good explain!

                 

                1. I want every 1 line text continue on 2 line to switch with the 3 line.

                2. After that automatically 3 line go to 2 line position. and than, 2 line text continue on 3 line to switch with the 4 line.

                 

                My text frame width: 340.157 pt

                 

                So it should go from this:

                 

                Line 1

                Line 1 continues

                Line 2

                Line 2 continues

                 

                To this:

                 

                Line 1

                Line 2

                Line 1 continues

                Line 2 continues

                 

                Below my screenshot. (This formatting following 1000 pages).

                 

                6.png

                 

                 

                I have mention that paragraph style "EXM". findWhat "EXM" style and reached that formatting text.

                 

                Please advice all Java King

                 

                Thanks in Advance

                • 5. Re: Formatting Text (cut and paste)
                  JanCE Level 1

                  Hi Karthiks, I have an idea but it requires a bit of work with Find and replace, Grep and Nested styles...

                  But neccessary condition is to know how to recognize end of lines 1 and 3 - Are there soft line breaks?, or does each line have a certain number of tabulators in it? This is necessary for constructing GREP expressions for Find and Replace. (If there is no such thing, than short script can tell where line breaks are and place soft line break character there - maybe someone here can write it for you)...

                   

                  The idea is to merge both paragraphs into one by GREP Find and Replace and have a forced-linebreak after each line (Shift+numpadEnter). Than with GREP Find and Replace to select lines into groups and replace them with groups in desired order 1-3-2-4. After that create neccessary character styles to format 2nd and 4th line and with Nested Styles apply that character styles to line 2 and 4... You are done - 1000 pages formated...

                   

                  jan

                  (don't forget to create backup of the document before you start with this approach - just in case...)

                  • 6. Re: Formatting Text (cut and paste)
                    JanCE Level 1

                    OMG - there is more simple solution - it just came to my mind

                    If we have two pragraph styles - one for lines 1 and 2 and second for lines 3 and 4:

                    1. set both paragraph styles to same leading (line spacing) of double the current value (let's say now it is 14 point so make it 28 points)

                    2. set baseline shift of second paragraph to 3*current line spacing (in this case 42 points)...

                     

                    woala...

                    (than if you will need to edit the texts use story editor, cause selecting baseline-shifted lines is complicated)

                    • 7. Re: Formatting Text (cut and paste)
                      karthiks94217840 Level 2

                      Hi all,

                       

                      @AriEss: Thanks to your replay!

                       

                      @JanCE: Your idea is very nice. I'm followed your way. I got the script line separate and separately (continued lines).

                       

                      @One more help: How to second line to switch with the third line? Desired order 1-3-2-4.

                       

                      Line 1 - separate line

                      Line 2 - separate line

                      Line 3 - separate line

                      Line 4 - separate line

                       

                      To this:

                       

                      Line 1 - separate line

                      Line 3 - separate line

                      Line 2 - separate line

                      Line 4 - separate line

                       

                      Please suggest friend. Please provide any sample link.

                       

                      Thanks in Advance

                      • 8. Re: Formatting Text (cut and paste)
                        Skemicle Level 3

                        This script will switch lines two and three of every textbox with the "EXM" paragraph style applied. See http://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-o r-blog-post.php  for information on installing and using this script.

                         

                         

                        /*

                        Scripted by Skemicle

                        */

                        if (parseFloat(app.version) < 6)

                        main();

                        else

                        app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Switch lines 2 and 3");

                        function main() {  

                            var doc = app.activeDocument;

                            var txtbox = doc.textFrames;

                            for(a=0;a<txtbox.length;a++){

                                var paras = txtbox[a].parentStory.paragraphs;

                                if (paras[0].appliedParagraphStyle.name == "EXM"){

                                    paras[1].contents = paras[2].contents + paras[1].contents;

                                    paras[3].contents = "";

                                }

                            }

                        }

                        • 9. Re: Formatting Text (cut and paste)
                          karthiks94217840 Level 2

                          Hi friends,

                           

                          @AriEss.

                          @JanCE.

                          @Skemicle.

                           

                           

                          Thank you so mach.