1 Reply Latest reply on Jun 4, 2014 3:49 AM by Chinnadk

    I am trying to resize page in millimeter

    Mani mohan Level 1

      I am trying to resize page in millimeter. It's wrongly resizing. Please advice

       

      Script:

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

       

      var myTemplate = File.openDialog("Choose A Template");

      var myFolder = Folder.selectDialog("Choose Folder Contains XML");

      var myXMLs = myFolder.getFiles("*.xml");

      {

      for (i = 0; i < myXMLs.length; i++)

      {

       

          var mydoc = app.open(myTemplate);

      mydoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;

      mydoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;

      app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR; 

      mydoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

      mydoc.importXML(myXMLs[i]);

       

          var mySpn = mydoc.xmlElements[0].evaluateXPathExpression("//Spine_mm[@SpineWidth]")[0].xmlAttributes. item("SpineWidth").value;

       

          var spineWidth = mySpn; //* 2.83464567;

       

          var mypages = mydoc.pages;

          var myPage = mypages.item(1);

          var myPbounds = myPage.bounds;

          var actualWidth = myPbounds[3] - myPbounds[1];

       

      for (var txtCnt = 0;txtCnt< myPage.textFrames.count() ; txtCnt++)

      {

          var myFrame = myPage.textFrames.item(txtCnt);

         

          var myTbounds = myFrame.geometricBounds;

       

          app.activeWindow.transformReferencePoint = AnchorPoint.LEFT_CENTER_ANCHOR;//CENTER_ANCHOR; 

          var Y1 = myTbounds[0];    var X1 = myTbounds[1];    var Y2 = myTbounds[2];    var X2 = myTbounds[3];

       

          myFrame.geometricBounds = [Y1 , X1, Y2, X1  + spineWidth];

      }

          var SpnStl = mydoc.paragraphStyles.item("Spine Text");

         

          var widh =spineWidth * 1;

       

          var heig = 224;

       

          myPage.resize(CoordinateSpaces.innerCoordinates, AnchorPoint.LEFT_CENTER_ANCHOR, ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[widh, heig]);

          }

      }

       

      xmlFile:

       

      <?xml version="1.0" encoding="ISO-8859-1"?>

      <MyBook xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">

      <ISBN href="../ImportBarcode/9780230300866.eps"/>

      <Spine_mm SpineWidth="22.64"><ttl aid:pstyle="SP_BKTTL">The Right Kind of History</ttl>|TAB|<au aid:pstyle="SP_AUTHOR">David Cannadine, et al.</au></Spine_mm>

      <Contributors>

      <ContributeLvl aid:pstyle="FC_AUTHOR">David Cannadine</ContributeLvl>

      <ContributeLvl aid:pstyle="FC_AUTHOR">Jenny Keating</ContributeLvl>

      <ContributeLvl aid:pstyle="FC_AUTHOR">Nicola Sheldon</ContributeLvl>

      </Contributors>

      <Title aid:pstyle="FC_BKTTL">The Right Kind of History</Title>

      <Subtitle aid:pstyle="FC_BKTTL">Teaching the Past in Twentieth-Century England</Subtitle>

      </MyBook>