6 Replies Latest reply on Jul 4, 2011 4:35 AM by praveen mds

    Text file output

    praveen mds Level 1
      var a = this.getAnnots();
      var Report = new Report();
      for(i=0; i<a.length; i++){
          if ( a != null ) {
              var p = a[i].getProps();
              for ( o in p )
              Report.writeText( o + " : " + p[o] );
          }
      }
      Report.save("/c/temp/myreport.pdf");
      

       

      This script gets the property of all annotations in a pdf file and makes it as a pdf output.

       

      How to get the report file in txt format?

       

      --

      Praveen

        • 1. Re: Text file output
          Bernd Alheit Adobe Community Professional & MVP

          Look at the method saveAs.

          • 2. Re: Text file output
            praveen mds Level 1
            Report.saveAs("/c/temp/myreport.txt", "com.adobe.acrobat.plain-text");
            

             

            Dear Bernd

             

            Is the right way to proceed? its not working for me.. what i'm doing wrong.

             

            Praveen

            • 3. Re: Text file output
              gkaiseril MVP & Adobe Community Professional

              Where are you running that script?

               

              Are you getting any conosle errors?

              • 4. Re: Text file output
                Bernd Alheit Adobe Community Professional & MVP

                Use this:

                app.openDoc("/c/temp/myreport.pdf");
                this.saveAs("/c/temp/myreport.txt", "com.adobe.acrobat.plain-text");

                • 5. Re: Text file output
                  praveen mds Level 1

                  Thanks Bernd,

                  app.openDoc("/c/temp/myreport.pdf");
                  this.saveAs("/c/temp/myreport.txt", "com.adobe.acrobat.plain-text");

                   

                  When i execute this; Before opening the specified pdf, it saves my current file opened in acrobat as txt format.

                  i tried closing my currect file, it also not helps me. As acrobat takes time to open the file, it executes the next step.

                   

                  this.closeDoc()
                  app.openDoc("/c/temp/myreport.pdf");
                  this.saveAs("/c/temp/myreport.txt", "com.adobe.acrobat.plain-text");
                  


                  And its seems too complex, making a report to pdf and then to txt format. its better to have a direct txt file report.

                   

                  Any suggestions?

                  • 6. Re: Text file output
                    praveen mds Level 1

                    I'm running it with Batch sequence,

                     

                    This is my fine tuned script

                     

                    var a = this.getAnnots();
                    var b = this.documentFileName;var d = b.slice (0, -4);
                    var Report = new Report();
                    for(i=0; i<a.length; i++)
                     {
                     if ( a != null ) {
                          var p = a[i].contents;
                          var q = a[i].rect;
                          var r = a[i].page;
                          Report.writeText( "Contents: "+p+"    Page: "+(r+1)+"     XY_Coordinates: "+q );
                     }
                    }
                    Report.save("/c/temp/"+d+"_report.pdf");
                    this.closeDoc()
                    


                    All i need is the should be report in text format, rather than pdf.