What is the problem
In the previous tutorial, we saw How to Print Multiple Pages Using Flex PrintDataGrid. It works fine when your application just contains one big DataGrid. In the real world, however, you often need a combination of contains and controls like VBox, HBox, Text, Image, plus DataGrid. Then guess what? You still have trouble with the Flex print job.
In fact, this is not the only challenge you are facing… How about the Print Preview function? Why do you need it? Because we are in recession! Oh, yeah, your boss would try to squeeze every penny for the sake of Cost Reduce. No one likes to see you print 100 pages then realize it is a wrong report. Plus saving paper is good for our mother earth.
Unfortunately, till Flex 3, Adobe has not provided a good solution to either Multiple Pages Printing or Print Preview (without client-side installation like PDF Printer).
FlexReport
As I mentioned before, my first Flex job was to find a better way to print multiple pages. So I did a lot of research on the 3rd party solutions. I was quite frustrated at that time. It seemed like everyone was focusing on Flex Layout, Animation, and Backend System Integration. Nobody cared about such a lower level job – Print. No wonder Adobe is not in hurry to provide a better support for Flex Print.
Finally, there was one open source project got my attention. It’s called FlexReport. After thoroughly reviewed its source code and demo application, I would have to say FlexReport is by far the closet solution to the Flex Print problem.
You can find the information about the FlexReport from the following URLs:
1. FlexReport Introduction http://www.kemelyon.com/bts/2008/01/14/flexreport/ 2. FlexReport Demo Application http://www.kemelyon.com/flexreport/0_2rc1/ 3. FlexReport Source File Download http://www.kemelyon.com/flexreport/srcview/FlexReport.zip Notes: If you counter any troubles to run the original FlexReport from the above link. You can Download My Working Version Here. I fixed some class reference problems and ran it fine in Flex 3.
How can FlexReport help you
The best way to see how much FlexReport can help you is to Try It. Download a copy and run it in your Flex Builder.
I found FlexReport was pretty cool in the following 3 areas:
1. Print preview Provides a nice preview by generating print pages through Bitmaps. Has a built-in PDF Printer, No extra software required to end users. 2. Report layout Creates dynamic reports without knowing how many pages in advance. 3. Multi-page text printing Except PrintDataGrid, adds a PrintText for long Text printing.
What is FlexReport missing
The biggest problem of FlexReport is: it assumes your Flex Components (Controls and Contains) are mainly Vertical-Stacked. For example, you have a TextArea at the top, then a DataGrid starting after the bottom of the TextArea, then an Image after the DataGrid.
However, many corporate forms are not like that, they usually mix Vertical and Horizontal Layout. For instance, you may have 3 Labels, 2 Text Areas, and 2 Images horizontal-aligned while other 2 DataGrids, 2 Texts, 3 Images vertical-aligned. FlexReport might give you some weird results in this case.
Conclusion
FlexReport is a nice solution to none-critical Flex printing jobs. It enhances Flex Print function in terms of Print Preview, Report Layout, and Multi-page Text Printing. However, FlexReport still has some issues to handle complex corporate reports especially with mixed Vertical and Horizontal Layout.
So, how can you further improve from FlexReport? To do so, you need to know some concepts and implementations of Flex Framework. This will be covered in our next tutorial – Understanding Flex Print Job from A to Z.
Source:http://flextutorial.org/2009/06/02/printing-multiple-pages-using-flexreport/