3 Replies Latest reply on May 22, 2006 10:55 PM by TIPLVinay

    Printing HAVOC in Flex 1.5

    TIPLVinay Level 1
      I have tried the multipage printing from the TitleWindow inFlex 1.5 and successed .

      But sometime it hangout my application.

      Code Function:-

      function doPrintForm() {
      // Visible TextArea Contains Text ( 2 pgs to 6 pges)
      var currentScaleX:Number = msgnonvisual.scaleX;
      var currentScaleY:Number = msgnonvisual.scaleY;

      // Non Visual TextArea behind CanVas

      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=75;
      msgnonvisual.scaleY=75;
      msgnonvisual1.scaleX=75;
      msgnonvisual1.scaleY=75;
      msgnonvisual2.scaleX=75;
      msgnonvisual2.scaleY=75;
      msgnonvisual3.scaleX=75;
      msgnonvisual3.scaleY=75;
      msgnonvisual4.scaleX=75;
      msgnonvisual4.scaleY=75;
      msgnonvisual5.scaleX=75;
      msgnonvisual5.scaleY=75;
      msgnonvisual6.scaleX=75;
      msgnonvisual6.scaleY=75;


      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 rintJob = 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;
      // Every line ends with ' and one nonvisual textarea can contains 42 lines.
      inxnum=msgtext.indexOf("'",startpoint);
      startpoint=inxnum;

      pj_array[countindex]=inxnum;
      countindex++;
      if(countindex%42==0 && countindex>41)
      {

      var endidx:Number=srtidx+41;
      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.addPage(msgnonvisual, {xMin:0,xMax:600,yMin:0,yMax:600});
      }else if(countpj==2)
      { msgnonvisual1.text=printtext.substring(pj_array[srtidx],actendindex);
      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      pj.addPage(msgnonvisual1, {xMin:0,xMax:600,yMin:0,yMax:600});
      }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.addPage(msgnonvisual2,{xMin:0,xMax:600,yMin:0,yMax:600});
      }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.addPage(msgnonvisual3, {xMin:0,xMax:600,yMin:0,yMax:600});
      }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.addPage(msgnonvisual4,{xMin:0,xMax:600,yMin:0,yMax:600});
      }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.addPage(msgnonvisual5, {xMin:0,xMax:600,yMin:0,yMax:600});
      }
      srtidx=srtidx+41;
      countpj++;
      }

      }

      if(countindex > 41)
      {
      var arrlen:Number=pj_array.length;
      --arrlen;
      var actendindex:Number=pj_array[arrlen];
      actendindex++;
      msgnonvisual6.text=printtext.substring(pj_array[srtidx]+1,actendindex);
      var temp = mx.core.UIObject.useLayoutManager;
      mx.core.UIObject.useLayoutManager = false;
      mx.managers.LayoutManager.updateNow();
      mx.core.UIObject.useLayoutManager = temp;
      pj.addPage(msgnonvisual6, {xMin:0,xMax:600,yMin:0,yMax:600});
      }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.addPage(msgnonvisual6, {xMin:0,xMax:600,yMin:0,yMax:600});
      }

      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;
      }
      }


      It works but sometimes it hang out the application and flash player.

      Please suggest where the problem is


      Thanks in Advance!

      Vinay

      or mail :
      vinay4java@yahoo.com
        • 1. Re: Printing HAVOC in Flex 1.5
          ntsiii Level 3
          Put some trace statements in the function, and run it til it hangs. The trace statements will tell you how far it got. Add some more traces around that and soon you will be able to pin down the exact line that is causing the problem.

          Knowing that might suggest a solution.

          Tracy
          • 2. Re: Printing HAVOC in Flex 1.5
            TIPLVinay Level 1
            I have traced but no error.
            It prints the document (Not as the User wants).But same error.
            .....flash player slow down....

            Application hang out..

            Is there another method to print single textarea with scrollbar(contains text for multiple pages) .

            Please give solution as it is the last task remained in my Application .
            I have sucessfully printed DataGrids with huge rerords (10-12 pages) and one page textarea without error,
            but when it comes to multipages APPLICATION HANG OUT.

            Anticipating a solution!

            Thanks in advance.

            • 3. Re: Printing HAVOC in Flex 1.5
              TIPLVinay Level 1
              Is there any solution for this?

              thanks in advance!

              vinay