5 Replies Latest reply on Jul 2, 2010 5:43 AM by sandy_88

    Each Special characters to image - urgent

    sandy_88 Level 1

      Hi Arivu,


      I am new to indesign scripting, you have given some script for me,  can u please tell me where i have to replace the below script in the script which you sent before. Please help me..


      matchedText[0].select();
              var myChar=app.selection[0].contents;
              var myFrame=aDoc.textFrames.add();
              myFrame.contents=myChar;
              myFrame.fit(FitOptions.frameToContent);
              myFrame.exportFile(1246775072, File(aDoc.filePath+'/'+convertUnicode(mySpecialText.charCodeAt(spchar))+".jpg") , false);
              myFrame.remove();




      Full Script which you sent first



      //Getting all characters
      var aDoc=app.activeDocument;
      for(var sto=0;sto<aDoc.stories.length;sto++)
      {
          myContents+=aDoc.stories[sto].contents;
         
          //Table
          for(var tbl=0; tbl < aDoc.stories[sto].tables.length; tbl++)
          {
              myContents+=aDoc.stories[sto].tables.item(tbl).contents;
              try{
              myContents+=aDoc.stories[sto].tables.item(0).rows.item(1).cells.item(0).tables. item(0).contents;
              }catch(err)
              {}
          }
      }


      //Filtering entity character
      for(var chr=0; chr < myContents.length; chr++)
      {
          if(mySpecialText.indexOf(myContents.charAt(chr)) < 0 && (myContents.charCodeAt(chr) !=65279 && (myContents.charCodeAt(chr) >127 || myContents.charCodeAt(chr)==9 || myContents.charCodeAt(chr) == 10 || myContents.charCodeAt(chr) == 36 || myContents.charCodeAt(chr) == 37 || myContents.charCodeAt(chr) == 38 || myContents.charCodeAt(chr) == 42 || myContents.charCodeAt(chr) == 43 || myContents.charCodeAt(chr) == 47 || myContents.charCodeAt(chr) == 92 || myContents.charCodeAt(chr) == 60 || myContents.charCodeAt(chr) == 61 || myContents.charCodeAt(chr) == 62 || myContents.charCodeAt(chr) == 64 || myContents.charCodeAt(chr) == 94 || myContents.charCodeAt(chr) == 96 || myContents.charCodeAt(chr) == 124)))
          {
              mySpecialText+=myContents.charAt(chr);
          }
      }


      //Replacing Entity character to unicode character
      for(var spchar=0;spchar<mySpecialText.length;spchar++)
      {
          app.findTextPreferences=app.changeTextPreferences=null;
          app.findChangeTextOptions.caseSensitive = true;
          app.findChangeTextOptions.includeFootnotes = true;
          app.findChangeTextOptions.includeHiddenLayers = true;
          app.findChangeTextOptions.includeLockedLayersForFind = true;
          app.findChangeTextOptions.includeLockedStoriesForFind = true;
          app.findTextPreferences.findWhat=mySpecialText.charAt(spchar);
          app.changeTextPreferences.changeTo="#x"+convertUnicode(mySpecialText.charCodeAt (spchar))+";";
          aDoc.changeText();
      }


      Regards

      Sajeev

        • 1. Re: Each Special characters to image - urgent
          sudar1983_14 Level 2

          Take a full script here.

           

          var myContents="";
          var mySpecialText="";
          var scriptTitle="Entity2Unicode";

           

          //Getting all characters
          var aDoc=app.activeDocument;
          for(var sto=0;sto<aDoc.stories.length;sto++)
          {
              myContents+=aDoc.stories[sto].contents;
             
              //Table
              for(var tbl=0; tbl < aDoc.stories[sto].tables.length; tbl++)
              {
                  myContents+=aDoc.stories[sto].tables.item(tbl).contents;
                  try{
                  myContents+=aDoc.stories[sto].tables.item(0).rows.item(1).cells.item(0).tables.item(0).co ntents;
                  }catch(err)
                  {}
              }
          }

           

          //Filtering entity character
          for(var chr=0; chr < myContents.length; chr++)
          {
              if(mySpecialText.indexOf(myContents.charAt(chr)) < 0 && (myContents.charCodeAt(chr) !=65279 && (myContents.charCodeAt(chr) >127 || myContents.charCodeAt(chr)==9 || myContents.charCodeAt(chr) == 10 || myContents.charCodeAt(chr) == 36 || myContents.charCodeAt(chr) == 37 || myContents.charCodeAt(chr) == 38 || myContents.charCodeAt(chr) == 42 || myContents.charCodeAt(chr) == 43 || myContents.charCodeAt(chr) == 47 || myContents.charCodeAt(chr) == 92 || myContents.charCodeAt(chr) == 60 || myContents.charCodeAt(chr) == 61 || myContents.charCodeAt(chr) == 62 || myContents.charCodeAt(chr) == 64 || myContents.charCodeAt(chr) == 94 || myContents.charCodeAt(chr) == 96 || myContents.charCodeAt(chr) == 124)))
              {
                  mySpecialText+=myContents.charAt(chr);
              }
          }

           

          //Replacing Entity character to unicode character
          for(var spchar=0;spchar<mySpecialText.length;spchar++)
          {
              app.findTextPreferences=app.changeTextPreferences=null;
              app.findTextPreferences.findWhat=mySpecialText.charAt(spchar);
              var matchedText = aDoc.findText();
              if (matchedText.length > 0)
              {
                  matchedText[0].select();
                  var myChar=app.selection[0].contents;
                  var myFrame=aDoc.textFrames.add();
                  myFrame.contents=myChar;
                  myFrame.fit(FitOptions.frameToContent);
                  myFrame.exportFile(1246775072, File(aDoc.filePath+'/'+convertUnicode(mySpecialText.charCodeAt(spchar))+".jpg"), false);
                  myFrame.remove();
              }
          }

           

          function convertUnicode(code)
          {
              var newstr='';
              var hex=code.toString(16);
              if (code<0x10) { newstr='000'+hex; }
              else if (code<0x100) { newstr='00'+hex; }
              else if (code<0x1000) { newstr='0'+hex; }
              else { newstr=hex;}
              return newstr.toUpperCase();
          }

           

           

          Arivu...

          • 2. Re: Each Special characters to image - urgent
            sudar1983_14 Level 2

            Is it not the right way repeating the same question again and again. If you want discuss again continue the same discussion.

             

             

            Arivu..

            • 3. Re: Each Special characters to image - urgent
              sandy_88 Level 1

              I am really sorry for my attitude, actually I am new to this adobe group and indesign scripting too.

               

              The Script extracting the special characters as image file, but the characters are not visible in that image file.

              Sorry once again.

               

              Regards

              Sajeev

              • 4. Re: Each Special characters to image - urgent
                sudar1983_14 Level 2

                It is working fine for me, and also if you have huge chinese characters to your job, this is not the right way to represent in the epub file. If you want any further assistance please contact my mobile no: 9739088575.

                 

                 

                Arivu...

                • 5. Re: Each Special characters to image - urgent
                  sandy_88 Level 1

                  can you send me your mail id i will send the file through mail then you will easily analyze

                   

                  Sajeev