Adobe Flex provides a great functionality to print date especially with the DataGrid printing which enables you to print data in a grid view. You can even find many examples on how to use it. Most of the time is even simple to use for small projects.
The most requested functionality or even example was on how to preview the report before the user sent it to the printer.
I have searched for days hoping to find something suitable for previewing the data before print or PDF preview but I just found incomplete examples and pieces of code that led me nowhere.
Therefore I had to build my own print preview tool while I was working on our KreatX ExcellentGrid. This extended grid component has many functionalities and components that were design to be loosely coupled this was also the case of print preview tool which resulted to be a entirely reusable anywhere with any DataGrid or AdvancedDataGrid.
This example illustrates how the user can select a range of rows or the entire data set from the AdvancedDataGrid (or simple Flex DataGrid) and enables the user to hide or show the desired columns before print preview. The print preview window/tool reflects the changes instantly by calculating the dimensions and the number of pages and finally printing.
Flex doesn’t have the capability to communicate with installed printers there fore the user must select again the size and layout of the print, in other words the flex printing tool is just a preview of what it can print but not the end result if the user doesn’t select those options again.
This might be the only completed printing utility you can find for free online. Check it out by clicking on the image.
Besides printing, our application provides the possibility to generate PDF directly in the client side in the same preview window. In this example you can find useful code for an image screen capture of the preview to pdf generation.
Check out the example here
and the Print Preview SOURCE code of the printing component here
FOR THE ENTIRE SOURCE CODE, FLEX PROJECT ZIP, contact Avenir Cokaj on one of the following e-mail addresses:
Please NO GMAIL accounts because I can’t attach zip files.
You may contact me any time if you need some extra help integrating the code or for that matter anything related to Flex and ActionScript 3.