4 Replies Latest reply on May 29, 2014 6:00 PM by mim_Armand

    Canvas support in Indesign scripts?

    mim_Armand Level 1

      Hi there,

       

      short version:

      I was wondering if it is possible in any way to include auto generated raster content (Using canvas api for example) in in-design using JavaScript?

       

      Long version:

      I noticed that In-design supports a very old version of JavaScript, and since I'm pretty new to InDesign scripting I thought it's better to get informed about its capability / limitations before planing about what to do with it! I wrote a Javascript code (not in in-design script) that generates unique random patterns of motifs, now I'm interested if I can integrate it in in-design scripts so it would put one of this raster images in each page of an in-design document (IE: left and right side of each relatively facing pages);

      also since my first guess after studying a bit In-design's object-model documentation was that it is very much limited to just what is possible through the software UI itself (and not any/some thing new/more), then I was wondering (in that case) how much is it possible to hook an script to an external script, and sending and receiving data/vars between them; like putting both scripts in the same folder, the first one calls the other one giving it some info (document dimensions, etc.), the second script runs (outside of ID), put the images on disk and return to main script when it's done!! :/

      I have some other solution sketches as well in my mind, but wanted to have your input before doing anything ridiculous!! :-)))

       

       

      I really appreciate your in-put on this,

      thx, mim,

        • 1. Re: Canvas support in Indesign scripts?
          Laubender Adobe Community Professional & MVP

          @mim – JavaScript with InDesign is not JavaScript with a browser. And the "canvas" object is not part of InDesign's DOM (Document Object Model).

          In effect you are using ExtendScript with InDesign, Adobe's own version of some JavaScript, which has some (all?) Core-JavaScript in common with an older version of ECMA-Script.

           

          So no. You cannot use "canvas" with InDesign.

           

          Uwe

          • 2. Re: Canvas support in Indesign scripts?
            Laubender Adobe Community Professional & MVP

            Maybe in a future version of InDesign you can build an extension, that uses HTML5 (with CSS and JavaScript) that itself supports "canvas" and you can make a call-back to the ExtendScript API to draw something according to your calculations doing with "canvas" (or whatever you are doing with it).

             

            But you have to wait some time you can make it happen or having it tested.

             

            Uwe

            • 3. Re: Canvas support in Indesign scripts?
              mim_Armand Level 1

              Thank you @Laubender,

              Is there a workaround then? like for example:

              We have access to file system here, right? (.exportFile()) if yes, then we can write data in a csv file and acquire those in the second script and letting the first script to know when everything is ready again by changing a var on the txt file as well! does it look feasible or is there any obstacle I'm not seeing here?


              Also is it possible to call / open an external file (like an exe or bat file) from within the in-design scripts?

               

              thx again, mim

              • 4. Re: Canvas support in Indesign scripts?
                mim_Armand Level 1

                And yeah! It looks like I can execute an external file of any type!

                After reading and looking for a while, finally:

                In 52th page of documentation it says:

                 

                execute()
                fileObj.execute ()
                Opens this file using the appropriate application, as if it had been double-clicked in a file browser. You can use this method to run scripts, launch applications, and so on

                 

                Voila! Exactly what I need (If what I think I need is actually what I need! indeed!!)

                I'll try to see if it works later on (impatient actually!), and thx again!

                ,mim