2 Replies Latest reply on Mar 26, 2009 2:58 AM by Kuldeep Atil

    Flex 3 Printing

    PKarpenko
      I've been banging my head against the wall trying to figure this out.
      I followed the example on livedocs, then an example in a Flex book I have (basically the same code) and nothing works.

      I have a PrintAdvancedDataGrid control in my mxml (I tried creating it dynamically in the code but that didn't work either) That has the same exact properties, including dataProvider as the grid I want to print.

      The result is that only what is currently visible in adgOriginal on screen gets printed and adgPrint.validNextPage is always false.

      Scrolling to the bottom of adgOriginal before printing does not change the printed output.

      Here's the control:

      <mx:PrintAdvancedDataGrid
      id="adgPrint"
      dataProvider="{adgOriginal.dataProvider}"
      width="{adgOriginal.width}"
      variableRowHeight="true"
      designViewDataType="tree"
      includeInLayout="false"
      visible="false">
      <mx:columns>
      [ .. three columns here .. ]
      </mx:columns>
      <mx:rendererProviders>
      [ .. a couple renderers here .. ]
      </mx:rendererProviders>
      </mx:PrintAdvancedDataGrid>

      In the AS, I have this:

      public function Print():void {
      var printJob:FlexPrintJob = new FlexPrintJob();
      if (printJob.start()) {
      addChild(adgPrint);

      adgPrint.validateNow();

      printJob.addObject(adgPrint, FlexPrintJobScaleType.MATCH_WIDTH);
      while (adgPrint.validNextPage) {
      adgPrint.nextPage();
      printJob.addObject(adgPrint, FlexPrintJobScaleType.MATCH_WIDTH);
      }
      printJob.send();
      removeChild(adgPrint);
      }
      }