Printing Complex Layouts in Adobe Flex – FlexPrintJob

I have come across a basic need for printing a complex layout in the Adobe Flex. After a long search i thought the following will be helpful to all if shared.

Requirements:

1. My layout has the following. Header (Fixed, to be shown in all page.), First Page Header (Displayed only in single page), DataGrid with data rolling out to more than one page, Fixed footer following the DataGrid and a Footer that come only in last page of the Printed output.
2. I am given only the outer most component object and list of all ids of the following components.
3. No server side support is available.

Problems:

1. My DataGrid is not accessible directly.
2. Complex layout and needed Paginationrn3. Fixed, floating header and footers.

Solution:

With reference to the Adobe Live docs, the solutions is almost near except to the complex structure.
rnI have created a Template that holds all the data to be iterated in the report. I contains the sections like Fixed Header, Floating Header, DataGrid, Fixed Footer, Floating Footer as follows.

1. PrintTemplate.mxml

<s:VGroup id="allPageHeader" width="100%" />
< s:VGroup id="firstPageHeader" width="100%" />
< mx:PrintDataGrid id="printDataGrid" width="100%" />
< s:VGroup id="allPageFooter" width="100%" />
< s:VGroup id="lastPagefooter" width="100%" />

2. PrintSample.mxml

protected function doPrint(outerGroup:DisplayObjectContainer, fixedHeaderIDs:ArrayCollection, floatHeaderIDs:ArrayCollection, dataGridId:String, floatFooterIDs:ArrayCollection , fixedFooterIDs:ArrayCollection):void{...}

Here we have to pass the list of IDs of the sections as we need to the doPrint method as follows.

doPrint(outerGroup, fixedHeaderIDs, floatHeaderIDs, dataGridId, fixedFooterIDs, floatFooterIDs);Completing the rendering the print object will be sent to printer and a popup will be shown.

Source Code: Printing in Adobe Flex

Update:

In the above example, if the Printout is taken with the printAsBitmap set to false, then there will be thick line under the header of the DataGrid ie, the PrintDataGrid. To solve this problem you have to use a Header Renderer and set a background color or Image for the header as follows.

<?xml version="1.0" encoding="utf-8"?>
< s:SparkSkin xmlns:fx="http:/s.adobe.com/mxml/2009" xmlns:s="library:/s.adobe.com/flex/spark" xmlns:mx="library:/s.adobe.com/flex/mx" > < s:Rect left="0" right="0" top="0"> < s:fill> < s:BitmapFill source="@Embed(''header.png'')"/> 
< /s:fill> < s:stroke> < s:SolidColorStroke color="grey" /> 
< /s:stroke> < /s:Rect>< /s:SparkSkin>

Save the file as SampleSkin and add this skin to the headerBackroundSkin property of PrintDataGrid in the PrintTemplate as follows.

<mx:PrintDataGrid id="printDataGrid" width="100%" headerBackgroundSkin="SampleSkin" />

This will resolve the issue and set a neat header to the DataGrid in the print.

God Mode in Windows 7

It may be hyperbolically named, but Windows 7’s God Mode is indeed
omnipresent. It conveniently puts hundreds of settings from all around
the operating system all in one place.
To turn on God Mode, create a new folder on your desktop, or anywhere
you’d like, and name it: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}.
Don’t include the final period. The resulting folder will contain 270
items, representing virtually every configurable option in Windows 7.

Regards,
Admin

Run multiple instances of messengers – Gtalk, Skype, Yahoo

Here are the ways that may help you use the messengers to login in more than one account.

For Gtalk :

1. Create  a shortcut for the Gtalk in the desktop and an extra arugument “/nomutex” in the ‘Target’ text box.

2. Now use the shortcut and run multiple instances of Gtalk as you like.

For Skype  :

1. You can do this in two ways for Skype. Create a shortcut for the skype in the desktop and add an extra argument “/secondary” in the ”Target’ , save the shortcut and run instances.

2. Skype can run an instance for every individual users. So create two or more users and use the following commmand from the shell to run instances. ‘ runas /user:XXX “C:Program FilesSkypeSkype.exe” ‘, where XXX is the username in your pc.

3. The above said way can also be done by right-clicking the shortcut and selecting the “Run As” command from the context menu.

For Yahoo :

1. Open the regedit ( Start -> Run -> regedit ), traverse to “HKEY_CURRENT_USERSoftwareyahoopagerTest”.

2. Create a DWORD registry value named “Plural” by right clicking the right hand side window.

3. Double click the new DWORD entry and set the value to 1.

Thats it. Run multiple instances of your favourite messengers and have fun. 😉

Tired of Social Network Sites and useless fake virtual friends

   Are you tired of the time wasting Social networking sites like Facebook.com, Twitter.com, and MySpace.com etc. Is it frustrating to go online because of the unknown contacts. Stop all those non sense by committing suicide online and learn to be lively in the real World with the help of Web2.0 Suicide Machine!!.

   This machine lets you delete all your energy sucking social-networking profiles, kill your fake virtual friends, and completely do away with your Web2.0 alter ego. The machine is just a metaphor for the website which moderator is hosting; the belly of the beast where the web2.0 suicide scripts are maintained. The service currently runs with Facebook, Myspace, Twitter and LinkedIn! Click here to Commit Suicide NOW!