2 Replies Latest reply on Jun 5, 2015 8:33 AM by KevinLecocq

    How to embed paths in an InDesign document using ExtendScript?

    KevinLecocq

      Hi,

      I have somes vector graphics in an Illustrator document that I need to embed in an InDesign document. To do that, I use javascript scripting targeting InDesign CS6.

      What I managed to do is placing the .ai in a rectangle in InDesign:

       

      var rectangle = page.rectangles.add();
      rectangle.geometricBounds = [15, 15, 15 + 30, 15 + 40];
      var aiFile = File("/d/test.ai");
      rectangle.place(aiFile);
      

       

      It works very well as I get my ai file fitting the rectangle. Nevertheless, it creates a link to the ai file, whereas I would like to embed each path of the draw into InDesign.

      Is there a way to copy vector graphics using scripts, like when you select, copy paste from Illustrator to InDesign?

        • 1. Re: How to embed paths in an InDesign document using ExtendScript?
          Laubender Adobe Community Professional & MVP

          Hi Kevin,

          you could unlink the link of the placed Illustrator file.

           

          In your case this would work like that:

           

          var rectangle = page.rectangles.add(); 
          rectangle.geometricBounds = [15, 15, 15 + 30, 15 + 40]; 
          var aiFile = File("/d/test.ai"); 
          rectangle.place(aiFile);
          
          //Embed the placed AI file:
          rectangle.graphics[0].itemLink.unlink();
          

           

          However, this is not the same as copying/pasting vector shapes from Illustrator to InDesign.

          The placed AI file remains an embeded file of type PDF on the page.

           

          If you want to copy/paste paths, you have to access Illustrator and InDesign by scripting, not placing files to InDesign.

          But there is a good chance, that you will end up with very strange constructs on the page in InDesign. Or you could fail for odd reasons. "Easy" vector paths might work, "complex" ones will not and throw errors.

           

          To access Illustrator you could use the BridgeTalk functionality of ExtendScript. Or maybe AppleScript, if you are on a Mac.
          See the Adobe Scripting Documentation for BridgeTalk or search this forum or the web. It's nothing for beginners, I'd say.

           

          Uwe

          • 2. Re: How to embed paths in an InDesign document using ExtendScript?
            KevinLecocq Level 1

            I just tested and it works very well.

             

            Thanks a lot for this exhaustive answer. I also see about this BridgeTalk.

             

            Another solution I was testing was to convert manually my .ai files to .indd files. So, targeting only InDesign in my script, I could open the other .indd then place the content in the first .indd:

             

            var placeAnotherIndd = function(inddFilePath, x, y, w, h) {

                var anotherDocument = app.open(File(inddFilePath));

                var mainGroup = anotherDocument.layers.item(0).groups.item(0);

                page.contentPlace(mainGroup, false, false, true, [x, y, w, h], document.layers.item(0), false);

                anotherDocument.close();

            }

             

            It also works but the content is not well placed at the specified x,y coordinates. I don't know why.