Here is an example of how to print a component to disk using Flex.
The basic idea is to grab the component as a new BitmapData Object, covert that to a PNG ByteArray and then use a FileReference to save the ByteArray to disk.
As you can see in the example here, you can pretty much output any object - and it won’t get clipped by the scrollbars on the browser page.
Here is the relevant code (the demo has view source enabled for full source code):
private function writeDGToDisk ( ): void {
var fr:FileReference = new FileReference();
var encoder:PNGEncoder = new PNGEncoder();
var bitmapData : BitmapData = new BitmapData(taskDataGrid.width, taskDataGrid.height, true, 0x000000);
bitmapData.draw(taskDataGrid);
var byteArrayData:ByteArray = encoder.encode(bitmapData);
fr.save(byteArrayData,"datagrid.jpg");
}
Enjoy.
Caspar
Related posts:
- Flex TitleBox Component For a recent project I was working on, I needed...
- Flex Uploader / Viewer Component Part 1 - Using the FileReference Class The aim of this series of 3 blogs is to...
- Flex Uploader / Viewer Component Part 3 - Tying It All Together This is the third post in a series of 3...
- Flex Uploader / Viewer Component Part 2 - Setting up the PHP This is the second post in a series of 3...
- Bevel Gradient Component Here is a small example of one method of creating...
Related posts brought to you by Yet Another Related Posts Plugin.











Posted by charmer on October 7, 2009 at 7:06 pm
