10 Replies Latest reply on Jul 1, 2010 9:06 AM by sandy_88

    Exporting Special Character

    sandy_88 Level 1

      Hi,

       

      Is there any script for exporting special character from Indesign (i.e., ò, ô )

       

      Please do the needful its urgent.

       

      Regards,

      Sajeev

        • 1. Re: Exporting Special Character
          sudar1983_14 Level 2

          Please find the below script, which will convert all special characters to unicode value.

           

          //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.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();
          }

           

          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: Exporting Special Character
            sandy_88 Level 1

            Hi Arivu,

             

            the above script showing some error, can u please sort out.

             

            Sajeev

             

             

            Untitled-1.jpg

            • 3. Re: Exporting Special Character
              sudar1983_14 Level 2

              Add the below codes to the front.

               

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

               

               

              Arivu..

              • 4. Re: Exporting Special Character
                sandy_88 Level 1

                Hi Arivu

                 

                This script working great.. can u please tell me that is there any possibility of converting each special character to a image. Because it is useful for my epub process.

                 

                And Thanks for your script Arivu..... great script...

                 

                 

                Regards

                Sajeev

                • 5. Re: Exporting Special Character
                  sudar1983_14 Level 2

                  It is not necessary for converting all special characters to image for epub process. I think so.. since it will support unicode and decimal values.

                   

                   

                  Arivu....

                  • 6. Re: Exporting Special Character
                    sandy_88 Level 1

                    For special characters unicode is enough but iam having some chinese characters in that indesign file what i have to do

                    Please help me...

                     

                     

                    Regards

                    Sajeev

                    • 7. Re: Exporting Special Character
                      sudar1983_14 Level 2

                      In my knowledge, there is no option to export a particular character. We have option for export a particular frame.

                       

                       

                      Arivu...

                      • 8. Re: Exporting Special Character
                        sandy_88 Level 1

                        what you people will do for epub when a chinese or arabic characters comes

                         

                        Sajeev

                        • 9. Re: Exporting Special Character
                          sudar1983_14 Level 2

                          We can load the chinese characters to the epub files. The below script will generate the jpg image for all the special characters. But it will take time to generate. Change the particular part from the old script.

                           


                                  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();

                           

                           

                          Arivu...

                          • 10. Re: Exporting Special Character
                            sandy_88 Level 1

                            Thanks Arivu,

                             

                            It really works, thanks a lot....

                             

                            Sajeev