2 Replies Latest reply on May 26, 2015 5:30 AM by jdejo

    TextFrame.contents encoding

    jdejo Level 1

      Hi Guys,


      Could someone drive me howto use international characters in IDS (e,g. Latin-2) via com.adobe.ns.InDesign.soap (java SOAP) and IDS javascript, please.


      a) If I send an utf-8 string to IDS side, then it generates the corresponding PDF with correct characters, but reading the same content back then the characters are already wrong (it seems a character encoding problem)


      b) if I use base64 encoding in both sides to send and receive characters between the java side and js then the reading contains correct characters, but the PDF has wrong encoding chars.


      Thanks in advance,


        • 1. Re: TextFrame.contents encoding
          [Jongware] Most Valuable Participant

          Javascript strings are not UTF8 encoded, they already are 16-bit Unicode characters (and higher values are encoded as 2-character surrogate pairs). Can you give an example of how "reading the content back" returns bad characters? It sounds like your workflow assumes all characters need translating, both back and forth.

          • 2. Re: TextFrame.contents encoding
            jdejo Level 1

            Hi Jongware,


            Thanks for the suggestion! Converting the contents of the TextFrames in javascript from UTF-16 to UTF-8 solved my problem. For other compatibilities I still kept the base64 encoding-decoding, too. My reading looks like this now:




                 var allTextFrames = myDocument.textFrames;

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

                      var tf = allTextFrames[i];

                      var content = my_util.toBase64StringFromUTF8Array(my_util.toUTF8Array(tf.contents));






                 String content = new String(Base64.decodeBase64(content.getBytes()));



            Thanks again,