Printing Multiple Pages using FlexReport

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.

About Bryan
Bryan Li has more than 10 years business consulting and project development experience with major corporate clients including Sony, Bank of Montreal, Bruce Power, etc. As a fan and advocate for RIA(Rich Internet Application) technologies, Bryan helps companies and developers learn, design, and build richer applications using Adobe Flex.

56 Comments on Printing Multiple Pages using FlexReport

  1. A workaround for fixing the blank page issue on Windows clients, is to remove the following attributes from the element in org.print.Page.mxml:

    backgroundColor=”#FFFFFF”
    borderColor=”#FFFFFF”
    themeColor=”#FFFFFF”

    Hope that helps!

    Chris

  2. Hi guys,
    I used the flex report & it was co0l…. thx;-)
    but when I tested the app with a printer, I also have the blank page problem.(I’m a windows user)
    I couldn’t find
    backgroundColor=”#FFFFFF”
    borderColor=”#FFFFFF”
    themeColor=”#FFFFFF”
    elements… could you please give me a solution for this?
    thanks ;-)

  3. Using
    ReportDataGrid and
    <mx:DataGridColumn headerText="Número Item" dataField="num_item" wordWrap="true"
    It is not correct to break pages.

    wordWrap="true" is necessary

    Can you help me?

  4. Meenakshi // April 26, 2011 at 7:51 am //

    Hello,

    Excellent articles are the one you posted.I have a VBOX consisting of panels,labels,header,textareas.I wanna print that.Though it prints in multiple pages with the help of FlexPrintJobScaleType.MATCH_WIDTH,I could not see a neatly formatted report like your sample.Please guide me how to achieve this.

    Thanks,
    Meenakshi

  5. abhishek // May 16, 2011 at 5:57 am //

    how we can assign list multi couln values to flex report ?
    :)

  6. I have started from this example to create my own print preview tool, now it is a tool which it can be used anywhere because it is designed to independent check it out at:
    http://blog.kreatx.com/2011/11/11/flex-printing-and-pdf-with-preview-window/

1 2

Leave a comment

Your email address will not be published.

*