1 Reply Latest reply on Jun 28, 2006 10:37 PM by TIPLVinay

    Flex 1.5 -PRINTING MULTIPLE PAGES

    TIPLVinay Level 1
      hi,
      plz tell me how to print multiple pages in flex 1.5.
      i hv used the fillowing function.it works well but sometimes it HANGS OUT the application.

      function doPrintForm() {

      var currentScaleX:Number = msgnonvisual.scaleX;
      var currentScaleY:Number = msgnonvisual.scaleY;
      var currentScaleX1:Number = msgnonvisual1.scaleX;
      var currentScaleY1:Number = msgnonvisual1.scaleY;
      var currentScaleX2:Number = msgnonvisual2.scaleX;
      var currentScaleY2:Number = msgnonvisual2.scaleY;
      var currentScaleX3:Number = msgnonvisual3.scaleX;
      var currentScaleY3:Number = msgnonvisual3.scaleY;
      var currentScaleX4:Number = msgnonvisual4.scaleX;
      var currentScaleY4:Number = msgnonvisual4.scaleY;
      var currentScaleX5:Number = msgnonvisual5.scaleX;
      var currentScaleY5:Number = msgnonvisual5.scaleY;
      var currentScaleX6:Number = msgnonvisual6.scaleX;
      var currentScaleY6:Number = msgnonvisual6.scaleY;
      var tempHeight=msgnonvisual.height;

      msgnonvisual.height=800;
      msgnonvisual1.height=800;
      msgnonvisual2.height=800;
      msgnonvisual3.height=800;
      msgnonvisual4.height=800;
      msgnonvisual5.height=800;
      msgnonvisual6.height=800;

      msgnonvisual.scaleX=65;
      msgnonvisual.scaleY=65;
      msgnonvisual1.scaleX=65;
      msgnonvisual1.scaleY=65;
      msgnonvisual2.scaleX=65;
      msgnonvisual2.scaleY=65;
      msgnonvisual3.scaleX=65;
      msgnonvisual3.scaleY=65;
      msgnonvisual4.scaleX=65;
      msgnonvisual4.scaleY=65;
      msgnonvisual5.scaleX=65;
      msgnonvisual5.scaleY=65;
      msgnonvisual6.scaleX=65;
      msgnonvisual6.scaleY=65;

      var msgtext:String=msgta.text;
      var printtext:String=msgta.text;

      var inxnum:Number;
      var actendindex:Number;

      var srtindstr:String="";
      var countindex:Number=0;
      var countpj:Number=1;
      //var SS:String="";
      var srtidx:Number=0;

      var pj_array:Array = new Array();
      var pj:PrintJob = new PrintJob();


      if(pj.start() != true){
      delete pj;
      return;
      }
      try{
      for (var startpoint:Number=0;startpoint<msgtext.length;startpoint++)

      {
      var temp = mx.core.UIObject.useLayoutManager;
      inxnum=msgtext.indexOf("'",startpoint);
      startpoint=inxnum;

      // trace("FLEX ERROR ->>>>>>>>>>----->>>.>>>>>>>.>>>>>>>"+startpoint );

      pj_array[countindex]=inxnum;
      countindex++;
      if(countindex%49==0 && countindex>48)// ||(printtext.length-startpoint)<34
      {
      var endidx:Number=srtidx+48;
      actendindex=pj_array[endidx];
      actendindex++;

      if(countpj==1)
      {
      msgnonvisual.text=printtext.substring(0,actendindex);

      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual, {xMin:0,xMax:900,yMin:0,yMax:700});
      }else if(countpj==2)
      {
      msgnonvisual1.text=printtext.substring(pj_array[srtidx]+1,actendindex);

      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual1, {xMin:0,xMax:900,yMin:0,yMax:700});

      }else if(countpj==3)
      {
      msgnonvisual2.text=printtext.substring(pj_array[srtidx]+1,actendindex);

      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual2,{xMin:0,xMax:900,yMin:0,yMax:700});

      }else if(countpj==4)
      {
      msgnonvisual3.text=printtext.substring(pj_array[srtidx]+1,actendindex);

      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual3, {xMin:0,xMax:900,yMin:0,yMax:700});

      }else if(countpj==5)
      {
      msgnonvisual4.text=printtext.substring(pj_array[srtidx]+1,actendindex);

      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual4,{xMin:0,xMax:900,yMin:0,yMax:700});

      }else if(countpj==6)
      {
      msgnonvisual5.text=printtext.substring(pj_array[srtidx]+1,actendindex);

      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual5, {xMin:0,xMax:900,yMin:0,yMax:700});

      }
      srtidx=srtidx+48;
      countpj++;

      }

      }

      if(countindex > 48)
      {
      var arrlen:Number=pj_array.length;
      // var lendiff:Number=arrlen-srtidx;
      // mx.controls.Alert.show("Length Diff"+lendiff,"CCS");
      --arrlen;
      var actendindex:Number=pj_array[arrlen];
      actendindex++;
      msgnonvisual6.text=printtext.substring(pj_array[srtidx]+1,actendindex);
      // mx.controls.Alert.show(pj_array[srtidx]+"\n"+actendindex,"CCS");
      var temp = mx.core.UIObject.useLayoutManager;
      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual6, {xMin:0,xMax:900,yMin:0,yMax:700});
      }else
      {
      msgnonvisual6.text=printtext;
      var temp = mx.core.UIObject.useLayoutManager;
      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      //pj.orientation == "landscape";
      pj.addPage(msgnonvisual6, {xMin:0,xMax:900,yMin:0,yMax:700});
      }

      pj.send();
      }finally
      {
      msgnonvisual.height=tempHeight;

      msgnonvisual1.height=tempHeight;

      msgnonvisual2.height=tempHeight;

      msgnonvisual3.height=tempHeight;

      msgnonvisual4.height=tempHeight;

      msgnonvisual5.height=tempHeight;

      msgnonvisual6.height=tempHeight;
      var temp = mx.core.UIObject.useLayoutManager;
      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;

      msgnonvisual.text="";
      msgnonvisual1.text="";
      msgnonvisual2.text="";
      msgnonvisual3.text="";
      msgnonvisual4.text="";
      msgnonvisual5.text="";
      msgnonvisual6.text="";

      msgnonvisual.scaleX=currentScaleX;
      msgnonvisual.scaleY=currentScaleY;
      msgnonvisual1.scaleX=currentScaleX1;
      msgnonvisual1.scaleY=currentScaleY1;
      msgnonvisual2.scaleX=currentScaleX2;
      msgnonvisual2.scaleY=currentScaleY2;
      msgnonvisual3.scaleX=currentScaleX3;
      msgnonvisual3.scaleY=currentScaleY3;
      msgnonvisual4.scaleX=currentScaleX4;
      msgnonvisual4.scaleY=currentScaleY4;
      msgnonvisual5.scaleX=currentScaleX5;
      msgnonvisual5.scaleY=currentScaleY5;
      msgnonvisual6.scaleX=currentScaleX6;
      msgnonvisual6.scaleY=currentScaleY6;

      delete pj;
      }
      }


      msgnonvisual,msgnonvisual1, msgnonvisual2, msgnonvisual3, msgnonvisual4,msgnonvisual5,msgnonvisual6 are the non visual TextArea 's filled at runtime.
      can anyone guide me?

      thanks in advance!

      vinay