One of the most significant enhancements to 2.9 is the introduction of Asynchronous printing. This not only gives your users a responsive UI and progressive feedback of the printing/pdf generation process, but also prevents flash time-outs in certain cases where the number of requested pages to print was large.
The way print and pdf generation are implemented is a little different between classic and Ultimate/Dashboard. The way it works in Classic is that the PDF trigger code lies outside the core library (specifically, in MyPreviewRenderer.mxml that is distributed as a part of the sample code). For Ultimate, the PreviewRenderer is built into the swc, so you do not have to do any manual work. This also means that we are able to enable this new feature by default for Ultimate, but for Classic, this has to be done manually.
So, for Classic customers (and any Ultimate customers if you have customized the Preview Window), first thing is that with 2.9, as soon as you drop the swc into your libs, you will see the following error.
1044: Interface method set progress in namespace com.flexicious.print.printareas:IPrintPreview not implemented by class com.sample.examples.support.print:MyPreviewRenderer. MyPreviewRenderer.mxml /Sample/src/com/sample/examples/support/print
There are two ways to resolve this issue, depending on what you need to do
1) You do not want to use the new Asynchronous Printing: Then just add the following code to your MyPreviewRenderer.
public function get progress():String
{
return "";
//do nothing
}
public function set progress(value:String):void
{
//do nothing
}
2) You want to use the new Asynchronous Printing:
- First, in MyPrintOptions.as, set printOptions.asynch=true.
- Use the MyPreviewRendererBelow.
- You will also need the AlivePDFPrinter, which is also attached. Drop it next to MyPreviewRenderer.
MyPreviewRenderer.mxml (8.21 kb) || AlivePdfPrinter.as (3.70 kb)
For Ultimate customers, the asynchronous printing is now the default. However, once you use 2.9, with the PDF, you will see the following error (Not only that, but the AlivePDFGenerator will also not be completely Asynchronous.):
Error: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
There are two ways to resolve the issue:
- You can live with the lag that is generated after the convert to image is complete and images are printed to PDF. If so, simply use the AlivePDFGenerator below.
AlivePdfGenerator.as (2.75 kb)
- You want to fully leverage the new Asynchronous Printing, including while generating the PDF. In this case, remove the AlivePDFGenerator altogether. You do not need it. On the FlexDataGrid, instead of
- < FlexDataGrid pdfBytesReady="new AlivePdfGenerator().generate(event.target as FlexDataGrid ,event.printOptions)", add:
- < FlexDataGrid pdfPrinter="{new AlivePdfPrinter()}". The AlivePDFPrinter class is shown below.
AlivePdfPrinter2.as (3.70 kb)
Once done, when you do the print, you should see a nice progress bar while the printing is in process.

There are a number of properties added to support this, but most of them default for Ultimate and for Classic, you simply have to use the appropriate classes as defined above. Dashboard currently only prints a one pager so it is not affected so much.
The following properties were added to support this functionality:
asynch:Boolean
Flag to enable asynchronous processing of the print results. If you set this to true, the pages are processed in timer events, giving the application an opportunity to show progress and prevent timeouts. Asynch can only work if you specify the preview flag, because the print then shows the progress in the preview window, and uses the preview window as a parent container.
asynchDelayCapture:Boolean
Flag to wait for the grid to completely render prior to capturing a snapshot for printing. The way the print works, is that it renders each page of the grid takes a snapshot and adds it to the print object to be spooled to the printer. Same concept applies to pdf where instead of adding to the print object the snapshot is converted to an image and added to the pdf bytestream. This does not work well in scenarios where you have external images that are loaded by url as opposed to using embedded assets. In scenarios like these you may need to add a delay to the printing mechanism to ensure that enough time is available for the external images to load. This flag, in combination with the asynchTimeInterval lets you control the amount of time that the print mechanism will wait after the grid is rendered to capture the snapshot.
This property can be used as the source for data binding.
asynchTimeInterval:int
The time interval, in milliseconds, used by the timer of the execute()
method to iteratively process pages. You can set it to a higher value if you want to wait for longer before the next page is processed. This is used in cases where you are loading external images in your item renderers. Please make sure you also set asynchDelayCapture to true in this scenario. The default value is 1, which allows enough time for the UI to update itself to show the end user a progress bar and also prevents timeouts while printing or exporting to pdf a large number of pages.
This property can be used as the source for data binding.
For Trials: Finally, if you see the following error when running the trial versions:
SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///C:/Users/Flexicious-106/Downloads/trials/FlexiciousUltimateFlex4Trial/bin-debug/TreeGrid.swf cannot access file:///C:/Users/Flexicious-106/Downloads/trials/FlexiciousUltimateFlex4Trial/bin-debug/TreeGrid.html.
Fix is to Right Click -> Global Settings -> Advanced -> Trusted Location Settings -> Add -> Add the folder above (The one where the swf is located).