15 Replies Latest reply on Aug 4, 2014 4:15 PM by HarveyLiu

    Is that possible to write a script for export underline text to PDF?

    HarveyLiu

      When I do some alteration in the financial document, I have to underline it aim to show what I have amend, those underline was called “markup“. And then print (hard copy) and gen (PDF) the amendment, which mean I have to print and gen the underline text (or called markup text) after  alteration.

       

      sample pic:

       

      back markup.jpg

       

       

      If:

       

      Client request a new version of markup which mean I have change the last markup color (last amendments’ underline color) into “back” and then make new markup to “red” like this:

       

      red markup.jpg

            

       

      What I want:

       

      is that possible to write a script for print and gen the markup text only in the all open document

       

      and I want two versions

       

      1) gen all the markup text no matter what the underline color

       

      2) gen the red color of markup text

       

      thanks!

        • 1. Re: Is that possible to write a script for export underline text to PDF?
          Trevorׅ Adobe Community Professional

          Post the PDF of the exact output you want for those files

           

          1 screenshot of the indesign file

          and screenshots of both PDF files

          • 2. Re: Is that possible to write a script for export underline text to PDF?
            HarveyLiu Level 1

            first I want go gen those pages in which have underline text, not matter what colour of underline, or how many underline text

             

            how many I have to pay for it?

            • 3. Re: Is that possible to write a script for export underline text to PDF?
              HarveyLiu Level 1

              two of pic was exact what I want to output

              • 4. Re: Is that possible to write a script for export underline text to PDF?
                HarveyLiu Level 1

                I write the script first, then I'll pay to you then you give me the script

                • 5. Re: Is that possible to write a script for export underline text to PDF?
                  Trevorׅ Adobe Community Professional

                  Send a link (public share) to the indesign source file and the PDF output files

                  Can't give any price until I get the files and fully understand what you want

                   

                  For you I would want partial payment before writing the script and partial payment afterward

                  • 6. Re: Is that possible to write a script for export underline text to PDF?
                    HarveyLiu Level 1

                    in a file, in which some have underline some not

                     

                    it was so simple, I just want gen the page in which have underline text, is that clear

                    • 7. Re: Re: Is that possible to write a script for export underline text to PDF?
                      Chinnadk Level 4

                      Hi HarveyLiu,

                       

                      Does this you ask? It will export the pages which have underlined text.

                       

                      var doc = app.documents;
                      app.findTextPreferences = null;
                      app.findTextPreferences.underline = true;
                      for(var i=0;i<doc.length;i++)
                      {
                              var found = doc[i].findText();
                              var _pages = [];
                              for(var j=0;j<found.length;j++)
                              {
                                      var txfms = found[j].texts[0].parentTextFrames;
                                      for(var k=0;k<txfms.length;k++)
                                      {
                                              _pages.push(txfms[k].parentPage.name);
                                          }
                                  }
                              for(var j=0;j<_pages.length;j++)
                              {
                                      if(_pages[j] === _pages[j-1])
                                      {
                                              _pages.splice(j,1);
                                          }
                                  }
                              if(_pages.length != 0)
                              {
                                      app.pdfExportPreferences.pageRange = _pages.toString();
                                      doc[i].exportFile(ExportFormat.PDF_TYPE, new File(doc[i].fullName.toString().replace(/\.indd$/i,".pdf")), false);
                                  }
                              _pages = [];
                          }
                      app.findTextPreferences = null;
                      

                       

                      Regards,

                      Chinna

                      • 8. Re: Is that possible to write a script for export underline text to PDF?
                        HarveyLiu Level 1

                        Thank you Chinna, thank you so much, geat for you to help, appreciate!

                         

                        but I still continued to seek my second version

                         

                        var doc = app.documents; 

                        app.findTextPreferences = null; 

                        app.findTextPreferences.underline = true; 

                         

                        app.findTextPreferences.underlineColour = red;     <-------------- Can I add this line?

                         

                        for(var i=0;i<doc.length;i++) 

                        var found = doc[i].findText(); 

                        var _pages = []; 

                        for(var j=0;j<found.length;j++) 

                                { 

                        var txfms = found[j].texts[0].parentTextFrames; 

                        for(var k=0;k<txfms.length;k++) 

                                        { 

                                                _pages.push(txfms[k].parentPage.name); 

                                            } 

                                    } 

                        for(var j=0;j<_pages.length;j++) 

                                { 

                        if(_pages[j] === _pages[j-1]) 

                                        { 

                                                _pages.splice(j,1); 

                                            } 

                                    } 

                        if(_pages.length != 0

                                { 

                                        app.pdfExportPreferences.pageRange = _pages.toString(); 

                                        doc[i].exportFile(ExportFormat.PDF_TYPE, new File(doc[i].fullName.toString().replace(/\.indd$/i,".pdf")), false); 

                                    } 

                                _pages = []; 

                            } 

                        app.findTextPreferences = null;

                         

                         

                         

                        • 9. Re: Is that possible to write a script for export underline text to PDF?
                          HarveyLiu Level 1

                          Hi, Chinna

                           

                          How can change it for second version of script:

                           

                          only gen the red colour of underline text to pdf?

                           

                          Best Regards,

                          Harvey

                          • 10. Re: Is that possible to write a script for export underline text to PDF?
                            HarveyLiu Level 1

                            Hi, Chinna

                             

                            Can you help me to fix a little problem?

                             

                            I want to add a folder into it?

                             

                            var doc = app.documents; 

                            app.findTextPreferences = null; 

                            app.findTextPreferences.underline = true; 

                            for(var i=0;i<doc.length;i++) 

                                    var found = doc[i].findText(); 

                                    var _pages = []; 

                                    for(var j=0;j<found.length;j++) 

                                    { 

                                            var txfms = found[j].texts[0].parentTextFrames; 

                                            for(var k=0;k<txfms.length;k++) 

                                            { 

                                                    _pages.push(txfms[k].parentPage.name); 

                                                } 

                                        } 

                                    for(var j=0;j<_pages.length;j++) 

                                    { 

                                            if(_pages[j] === _pages[j-1]) 

                                            { 

                                                    _pages.splice(j,1); 

                                                } 

                                        } 

                                    if(_pages.length != 0) 

                                    { 

                                            app.pdfExportPreferences.pageRange = _pages.toString(); 

                                            doc[i].exportFile(ExportFormat.PDF_TYPE, new Folder( myFolder.fsName + "/<-----Out Folder/" ), new File(doc[i].fullName.toString().replace(/\.indd$/i,".pdf")), false); 

                                        } 

                                    _pages = []; 

                                } 

                            app.findTextPreferences = null;

                             

                            but not work

                            • 11. Re: Re: Is that possible to write a script for export underline text to PDF?
                              Trevorׅ Adobe Community Professional

                              Hi Harvey

                               

                              You can use

                              app.findTextPreferences.underlineColor = "red";

                              Where Red is the name of the swatch but it must be in "quotes"

                              regarding the folder  issue you can use

                              doc[i].exportFile(ExportFormat.PDF_TYPE, new File("C:/my pdf exports folder/subFolder/" + doc[i].name.replace(/\.indd$/i,".pdf")), false);

                              Where "C:/my pdf exports folder/subFolder/" is the path of the folder. Take note of the / needed at the end of the folder name

                               

                              HTH

                               

                              Trevor

                              • 12. Re: Is that possible to write a script for export underline text to PDF?
                                HarveyLiu Level 1

                                Thanks Trevor

                                 

                                Thank you very much,

                                 

                                How can it credit a new folder in same folder as a subfolder

                                 

                                Harvey

                                • 13. Re: Re: Is that possible to write a script for export underline text to PDF?
                                  Chinnadk Level 4

                                  Second script:

                                   

                                  var doc = app.documents;
                                  app.findTextPreferences = null;
                                  app.findTextPreferences.underline = true;
                                  app.findTextPreferences.underlineColor = "red";
                                  for(var i=0;i<doc.length;i++)
                                  {
                                          var found = doc[i].findText();
                                          var _contents = [];
                                          if(found.length>0)
                                          {
                                              var _file = new File(doc[i].fullName.toString().replace(/\.indd$/i,".txt"));
                                              _file.open('w');
                                              for(var j=0;j<found.length;j++)
                                              {            
                                                      _file.write(found[j].contents + "\r");
                                                  }
                                          }
                                          _file.close();
                                      }
                                  app.findTextPreferences = null;
                                  
                                  

                                   

                                  Regards,

                                  Chinna

                                  • 14. Re: Is that possible to write a script for export underline text to PDF?
                                    HarveyLiu Level 1

                                    Thank you Chinna, Thank you very much

                                     

                                    Harvey

                                    • 15. Re: Is that possible to write a script for export underline text to PDF?
                                      HarveyLiu Level 1

                                      Hi, China

                                       

                                      I fund this script has problems, I mean gen pdf script, could you please help me to fix it?

                                       

                                      1) this script gen multi times for one page?

                                      2) if there are some text frame on desktop, and the text frame has underline text, it will give me an error

                                       

                                      thanks

                                       

                                      Regard

                                       

                                      Harvey