3 Replies Latest reply on Jun 2, 2014 10:30 AM by mim_Armand

    Indesign (IDML file) Viewer using HTML5 and Javascript

    krishnaraoveera1294 Level 1

      I’m working on IDML file automation. My requirement is to showcase an IDML template in an HTML5 editor.

      I have a simple TextFrame with Hello World text. I saved the file as: sample.idml. Then, I unzipped sample.idml and got a few files. Went to the stories folder and opened: story_d8.xml.

      Since I’m a developer, I did this using Java and exposed the file path as a REST call. The biggest stopping point is: the jQuery/AngularJS script is saying:invalid file.

      Can someone suggest options to address the points below:

      1. Get Content data using JavaScript (jQuery/AngularJS)
      2. Put "Demo Hello" in the Content and regenerate story_d8.xml (using JavaScript)
      3. Is this the correct approach? Are there alternative to this approach?

      Note: My Requirement is to modifying IDML file at client side (javascript) only.

        • 1. Re: Indesign (IDML file) Viewer using HTML5 and Javascript
          mim_Armand Level 1

          Hi @

           

          <!DOCTYPE html>

          <html>

              <head>

                  <meta charset="utf-8">

                  <meta http-equiv="X-UA-Compatible" content="IE=edge">

                  <title></title>

              </head>

              <body>

          <pre class="result"></pre>

                  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

                  <script src="//cdn.jsdelivr.net/jquery.xml2json/1.2/jquery.xml2json.js" type="text/javascript" charset="utf-8" async defer></script>

          <script type="text/javascript">

          var mim;

          $.ajax({

          type: "POST",

          url: "test.xml",

          dataType: "xml",

          success: function (data) {

                  mim = $.xml2json(data);

                  console.log(mim.Story.ParagraphStyleRange.CharacterStyleRange.Content);

          }

          });

          </script>

              </body>

          </html>

          mim,

          • 2. Re: Indesign (IDML file) Viewer using HTML5 and Javascript
            krishnaraoveera1294 Level 1

            Dear mim_armand

             

            I tried the same. By the way, i using xml file path from tomcat7 webserver. like "url: "http://localhost:8080/APP/idemlfp/test.xml"

             

            I'm getting CORS issue. My server not allowing me to read file from path.

             

            later, I tried "dataType:jsonp" , browser console shows JSON parse error but getting xml file structure. :=)

             

            i don't to know who to hack this. Kindly help out in this.

             

            you can reach me @ my skype id: "krishnaraoveera1294"

            • 3. Re: Indesign (IDML file) Viewer using HTML5 and Javascript
              mim_Armand Level 1

              Of-course You can't send requests to your server from anywhere just like that, if you wanna enable CORS on your server I guess your best bet is to looks somewhere else (not in InDesign extendScript forums) like here!

              Then if your server respond with XML to your requests (and you can't change it server-side) I don't know why you try json-p! you can't work around same-origin-policy like that on client-side! it's either jsonp (server-side) or CORS enabled, no other solution or hacks is possible!

              I'll be happy to help if I can but I can't do it in your place my friend

              Goodluck,

              m,