1 Reply Latest reply on Apr 17, 2012 7:50 AM by KevDev9

    Anchored Objects




      I'm currently trying to build a script to create anchored objects with a specific object style.


      Here's how my XML structure looks like...




      Every occurance of typ-block needs to be replaced with an anchored object. I already have an object style for it.


      For now, the script finds the xml elements(typ-block occurance).


      Now, I want to move the cursor infront of the xmlelement, create an anchored object and MOVE everything inside of typ-block(the whole structure(breaks,lists,...)) into the created anchored object.

      The anchored object should have a specific object style and width.


      This is my code so far.


      var xmlElements = app.activeDocument.xmlElements[0].xmlElements;
      var elemLength = xmlElements.length;
      for(var x = 0; x < elemLength; x++)
       if(xmlElements[x].markupTag.name == "kapitel")
       var xmlKapitel1 = xmlElements[x].xmlElements;
      var Kap1L = xmlKapitel1.length;
      for(var y = 0; y < Kap1L;y++)
          var xmlKapitel2 = xmlKapitel1[y].xmlElements;
          if(xmlKapitel1[y].markupTag.name == "kapitel")
             // fortfahren mit durchsuchen
             var Kap2L = xmlKapitel2.length; // Kapitel 2 Länge
             for(var z = 0; z < Kap2L; z++)
                var xmlKapitel3 = xmlKapitel2[z];
                if(xmlKapitel3.markupTag.name == "typ-block")
             } else if(xmlKapitel1[y].markupTag.name == "typ-block")
      function createMargin(xmlElement)
           var blockTyp = xmlElement.xmlAttributes[0].value;
          if(blockTyp == "ergaenzung")
          var insPoints = xmlElement.insertionPoints;    
          var ins1 = insPoints[0]; // this seems to be a good point to insert the anchored object
          var _doc = app.activeDocument;
          var _sel = app.selection[0];


      I do hope you can help me.


      Thanks in advance.

        • 1. Re: Anchored Objects
          KevDev9 Level 1

          I did get the creation of the frame working. Now I need to place the xmlelement into the textframe.


          Do you guys have any idea how I'm able to do so?


          _mtf.placeXML(xmlElement); // _mtf is the textframe





          Elements cannot be placed into an inline.