4 Replies Latest reply on Jun 6, 2008 12:00 PM by AICC

    Flex Printing is horrible

    shawnyale Level 1
      I have been trying rather unsucessfully for 2 days to print all of the items within a list. After watching a video and waiting for help, Ive come to the conclusion that Flex is not very good for printing.

      I have finally gotten my PrintDataGrid to print except it only prints 2 lines per page. I have changed the rowCount and every other property I can think of to get the darn thing to fill up a page.

      So now, after wasting at least a ream of paper and hours of time for what should be a relatively simple task, Ive come to the conclusion that perhaps Adobe, A PRINTING COMPANY, might want to put a little more effort into the printing aspect of Flex. IT SHOULD NOT BE THIS HARD TO PRINT A LIST OF ITEMS.

      Unfortunately, I dont have the luxury of using the DataGrid because the items are rendered from a component that determines their layout relative to the list. I've tried EVERYTHING I can think of...

      and am just disappointed.
        • 1. Re: Flex Printing is horrible
          shawnyale Level 1
          Here is my code is anyone is interested:

          // Print page function
          public function Print():void{
          var printJob:FlexPrintJob = new FlexPrintJob();
          var printView:PrintAllMeetings = new PrintAllMeetings();

          // Start the print job.
          if (printJob.start() != true) return;
          // Add the PrintAllMeetings object to the application
          addChild(printView);
          // Set the data provider and height / width
          printView.PrintMeetings.dataProvider = lstMeetings.dataProvider;
          printView.width = printJob.pageWidth;
          printView.height = printJob.pageHeight;


          // Add the Print All Meetings object to the print job
          printJob.addObject(printView);

          // Loop through all of the items in the list
          while(printView.PrintMeetings.validNextPage){
          printView.PrintMeetings.nextPage();
          printJob.addObject(printView);
          }
          // Send the print jbo to the printer
          printJob.send();
          // Remove the child Print All Meetings object from the application
          removeChild(printView);


          And my component PrintDataGrid:
          <mx:PrintDataGrid id="PrintMeetings" width="100%" >
          <mx:columns>
          <mx:DataGridColumn itemRenderer="common.MeetingListItemSmall"/>
          </mx:columns>
          </mx:PrintDataGrid>
          • 2. Flex Printing is horrible
            shawnyale Level 1
            Sorry if I sound crabby, Im just tired of fighting to get this thing to work.

            Im sure it works great if all I had to print was a couple football teams and divisions or something, but I have to print something "real"
            • 3. Re: Flex Printing is horrible
              Kotowsky Level 1
              Mate,

              I've spent full 7 working days trying to figure out how to control the printing. I've found a more or less satisfactory solution but only through a trial and error. There are so many variables that determine how the lists get printed that I cannot begin to imagine how to put it in writing. You should try with assigning various heights to your PrintDataGrids: no height, percent height (you may find that the same job prints OK with 74% but does not print OK with 75%), height in pixels and explicit height. Also font sizes matter. My print, e.g. works with 7 points font, but does not with 8 points. Certain properties fail to get set if you change the font size. But according to the video somebody's "manager is happy". I wrote the same message that for a printing company such as Adobe having printing in Flex at such a low level is a disgrace.

              In your case I would stretch your PrintDataGrid to the edge of the page so that it receives some height in pixels and then see how it works. BTW It would work differently if you'd create you PDG in action script and not MXML.(not necessarily right though, too).
              • 4. Re: Flex Printing is horrible
                AICC Level 1
                What you are suggesting, sounds like a recipe for disastor, if the deployment of the application is to several hundred computers.

                Has anyone come across solutions from flex or another adobe product that will print mulitple pages consistently.
                (with a variant size for row heights or a variation of any of the objects that will plug into the report).

                For example> I tried to print a datagrid that had a variation to row height. Sometime 5 lines of text needs to be printed while other times. 3 lines of text is printed.

                The only thing I could do so that the data grid rows would not "mess up" and print half rows and even skip rows was to make the row-height consistent for every datagrid record..

                example>
                <mx:PrintDataGrid id="myDataGrid" rowHeight="220" width="400" wordWrap="true">
                <!-- Specify the columns to ensure that their order is correct. -->
                <mx:columns>
                <mx:DataGridColumn dataField="Index" />
                <mx:DataGridColumn dataField="Qty" />
                <mx:DataGridColumn dataField="QtyDescription" wordWrap="true" width="150"/>
                </mx:columns>
                </mx:PrintDataGrid>

                I also noticed, it is hard to get page x of xx printed at the top or bottom of the page in a page header /page footer.

                Isn't their a simple report writer available for adobe products?
                similar to crystal reports, Microsoft Access reports, SQL Reporting services

                Doug Lubey of Louisiana
                www.douglubey.com

                search engine reference:
                adobe flex 3 printing examples