2 Replies Latest reply on Sep 12, 2009 8:39 PM by TheFlexGuy

    Flex Printing

    screen22876

      Dear All,

       

      I have a flex application and one of the modules generates a huge tree graphical component on the screen. There is a “Print” option to print the tree in the paper. Is it possible to print the whole tree in multiple papers? Currently we are printing this in a single paper which is not readable. Client wants to print the whole tree in multiple papers.

      Currently we are creating a image of it and sending to the printer for printing. Check the below code:

       

       

      private function getImage():Image
      {
      var node:UIComponent;
      var bitmap:BitmapData;
      var image:Image = new Image();
      switch( target.selectedItem.@value.toString() )
      {
        case "all":
        node = tree;
        break;
        case "selected":
        node = tree.getTreeItem( model.nodeManager.selectedNode ).container;
        break;
      }

      var bitmapWidth:int = node.width + 20;
      var bitmapHeight:int = node.height + 20;
      var scalingRatio:Number = 1;
      // BitmapData only supports maximum size of 2880x2880 pixels.
      if ( (bitmapWidth > 2880) || (bitmapHeight > 2880) )
      {
        // determine which dimension we'll have to scale by, width or height
        if ( bitmapWidth > bitmapHeight )
        {
        scalingRatio = 2880 / bitmapWidth;

        bitmapHeight = 2880 * bitmapHeight / bitmapWidth;
        bitmapWidth = 2880;

        }
        else
        {
        scalingRatio = 2880 / bitmapHeight;

        bitmapWidth = 2880 * bitmapWidth / bitmapHeight;
        bitmapHeight = 2880;
        }
      }

      //buffering image here by 10 px on each side due to the grouping arround nodes not included in layout
      bitmap = new BitmapData( bitmapWidth, bitmapHeight, false, 0xffffff );
      bitmap.draw( node, new Matrix( scalingRatio, 0, 0, scalingRatio, 0, 0 ) );
      image.source = new Bitmap( bitmap );
      tree.scaleX = treeScaleX;
      tree.scaleY = treeScaleY;
      return image;
      }

        

      Can it posible to generate multiple images based on width and height and send to the printer?

       

      I will appreciate if you have other suggetions. See the attachment for your ref.

       

      Thans,

      Susant