Many people have complained or indicated that they need or would like a print preview component. FlexReport seems to have had a short lifetime and the demo site has recently been suspended, so it’s no longer an option. We at Soph-Ware Associates, Inc. recently needed such a component — so we wrote one. Try it out here!
A Brief Warning
This is not even a pre-release, rather it’s a call for testers and release of some code, as-is, no-warantees, expressed-or-implied, etc. This release is not fully documented and should probably be considered an alpha release, although I believe it’s stable and useful.
Features and Implementation
This print preview component provides the ability to preview your document, zoom in or out, change between pages and, of course, print.
In order to use it, simply create a component that implements the com.sophware.printing.IPrintableDocument interface. That document can be a single component that uses something like PrintAdvancedDataGrid to handle the pagination, or a component that really aggregates a set of components into a single document, displaying the correct child component at the time nextPage or previousPage is called. It doesn’t really matter how it’s implemented, as long as that component behaves as expected.
Unlike FlexReport, the print preview is generated dynamically by Flex without resorting to rendering to a bitmap, so there isn’t any ugly pixelization (unless the component is designed that way).
A Flash Player Bug, Testers Needed
We haven’t had the time to do much polishing, and the version that I’m posting is scaled down a bit (no PDF support, etc.), but we hope you find it useful. It is serving us well, with one exception — there appears to be a bug in playerglobal.swc for Flash Player 10 that effects Internet Explorer and occasionally some other browsers.
Details of the bug report are available here. Despite the brevity of the bug report, we’ve worked extensively with Adobe (special thanks to Leah Zagreus who worked hard to try and isolate it on Adobe’s systems) and haven’t been able to make any progress.
We can reproduce this bug every time on our machines, but Adobe can’t. In order for us to reproduce the issue, we have to require version 10 of Flash Player. By passing -target-player 10.0.0 to mxmlc when compiling using mxmlc, we often see a part of the document obscured in the printout, despite a perfect preview:

Band appears horizontally across page, obscuring content.
We’ve seen the bug on both Windows and Macintosh and under Firefox, Internet Explorer, and Safari. For us, it’s consistently reproducible under Internet Explorer (7 and 8) and Safari.
So, if you’ve been needing a print preview component and/or could test this out on your browser and leave a comment if you see it, please do! If we can resolve this issue soon, we might still have some time to make this into a high-quality, production-ready component.
If you’d like, download the source here.
Dear Kaleb, I found interesting your PrintPrewiev control. I have a question that i cant solve several weeks. My document contains 6 similar pages with only different photo and label from array that linked to “currentpage”. The control draws all the stuff perfectly, but when i send it to pdf printer, loop “while(document.validNextPage)” causes document dosnt have enough time to complete creation of image on page and all pages of resulting pdf are similar to first one. How to solveit?
Flex currently has a 60 second timeout on print jobs, so do as much processing as you can before you actually start printing. Two different things will likely help:
1. Lower both the desiredHeight and desiredWidth attributes. By making these smaller, the page you’re printing won’t need to be scaled down as much.
2. When converting to a PDF, use a lower DPI/resolution. We chose to go with a resolution that allows us to zoom in between 200 and 300% before we see degradation. Using a higher DPI allows better zooming but otherwise slows processing down.
Good luck.
Dear Kaleb,
Thank you for detailed answer. Still cannot solve a problem. My example is very simple. I set number of pages to 6 and I have modified “NextPage” function of the printable document. Modified NextPage simply changes source of an ImageBox on a page. As a result I have 6 pages with different Images near the text. Then I run an application and easily navigate Next page until i reach last one. The code works and pages are properly diplayed inside a popup window. However, when I press “print” button, final PDF or print-out either does not contain picture or contains all the same pictures identical to first one. The reason, that all the functions are immediately (less than 2 seconds) performed without waiting for document to be entirely rendered. I tried to remove images and leave only text. It works fine, but when i place images, the print-outs are wrong.
Hi,
I have tried ur concenpt in my Application, its working fine. but i am facing problem in Print Prreview.
I have lengthy value in some of the datagrid column, so i could not see the values fully in the print preview, but i can see those things in paper.
i tried with variablerowheight and wordwrap in datagrid, still the problem exist !
if u have any idea kindly share with me.
regards
areef
Areef, I’m not sure why the preview would show something different from the printout, aside from some font embedding issues that don’t seem related. You might try asking on the Flex Coders mailing list.
Hi,
I would like to ask how to remove the “flex data visualization trial”. Thank you
You get a license of the Flex Data Visualization packages when you buy Flex Builder Pro. The print preview component doesn’t require the data visualization components, although my example does. You can easily create print previews without using that component set.
Incoming Links
Trackback this post | Subscribe to the comments via RSS Feed