8 Replies Latest reply: Apr 11, 2012 5:07 AM by SangeethaRajeshkumar RSS

    export Indesign snippet

    SangeethaRajeshkumar

      Export each spread in indesign as indesign snippet without using grouping.

        • 1. Re: export Indesign snippet
          [Jongware] MVP

          What, right now? Why should I?

          • 2. Re: export Indesign snippet
            SangeethaRajeshkumar Community Member

            While export snippet manually layers are not affected. But when i use script all the objects are grouped and snippet have only one layer instead of two layer. ( in original indesign file 2 layers are present).

            • 3. Re: export Indesign snippet
              Green4ever Community Member

              If you post your sample codes, you'll get quick fixes....

              • 4. Re: export Indesign snippet
                SangeethaRajeshkumar Community Member

                var myPages = app.activeDocument.spreads.length;

                var myObj = new Array();

                for(var i = 0; i < myPages; i++){

                    var myPage = app.activeDocument.spreads.item(i);

                     myObj = app.activeDocument.spreads.item(i).pageItems;

                    // alert (myText.parentTextFrames(0).parent.name);

                    var myGroup = app.activeDocument.spreads.item(i).groups.add(myObj,undefined,LocationOptions.UNKNOWN,app .activeDocument.spreads.item(i));

                    myGroup.exportFile(ExportFormat.INDESIGN_SNIPPET, File("/c/test/snippet-" + i + ".idms"));

                    myGroup.ungroup();

                }

                • 5. Re: export Indesign snippet
                  Green4ever Community Member

                  I searched and tried and cannot find a direct method to export a ungroupped objects in single snippet file.

                   

                  var obj = app.activeWindow.activePage.pageItems.everyItem();
                  obj.exportFile(ExportFormat.INDESIGN_SNIPPET, File("E:/testing.idms"));
                  

                  This method also fails, it exports only the first item in the array.

                   

                  Any way you have to group it. So that you'll have it in a single file.

                   

                  Try this work around, Add a label to indicate to which layer it belongs to, and while importing it run a script to move it to its corresponding layers based on the labels that you assigned.

                   

                  Green4ever

                  • 6. Re: export Indesign snippet
                    SangeethaRajeshkumar Community Member

                    I dont know how to add a label and move it to its corresponding layer. Can you help me.

                    • 7. Re: export Indesign snippet
                      Laubender MVP

                      To add a label you could use the insertLabel method:

                       

                      myPageItem.insertLabel("KeyString", "ValueString");
                      

                       

                      To extract it, do it like that:

                       

                      myValueString = myPageItem.extractLabel("KeyString");
                      

                       

                      To use a value like the name of a layer, you could:

                       

                      myPageItem.insertLabel("Layername", myPageItem.itemLayer.name);
                      

                       

                      To extract the layer name and apply it to the page item:

                       

                      myPageItem.itemLayer = app.activeDocument.layers.itemByName(myPageItem.extractLabel("Layername");
                      

                       

                      Of course you can run into problems if the layer does not exist in the document where you place your snippet.
                      In that case you have to add a new layer with the appropriate name to the document.

                       

                      app.activeDocument.layers.add({name:myPageItem.extractLabel("Layername")});
                      

                       

                      Or it may be that the layer is there, but locked! Then you first have to unlock teh layer.

                       

                      Also: that easy approach will not take care for the "right" order layers are stacked, if they are visible or even locked. Does the rules of the source or the target document layer behaviour apply? You may or may not implement a routine to get that right. This is highly case dependend. If one or some of the layers already exist and you mix that with new added layers or you change the stacking order of layers you could easily contradict already established layer behaviour and wreck the layout of a whole document…

                       

                      Uwe