<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: vbox xmlns: MX = "http://www.adobe.com/2006/mxml" xmlns = "*"
Backgroundcolor = "# ffffff"
Fontfamily = "simsun" fontsize = "12"
Paddingtop = "50" paddingbottom = "50" paddingleft = "30" paddingright = "30"
Height = "268" width = "748">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Controls. datefield;
Import MX. Core .*
Import MX. Collections. arraycollection;
Import MX. Printing .*;
[Bindable]
Private var pagenumber: Number = 1;
[Bindable]
Private var prodtotal: Number = 0;
[Bindable]
Private var reporttitle: String = "report title ";
[Bindable]
Private var datetime: String = "";
Public Static Var footerheight: Number = 20;
Public Static Var prodindex: number;
Public Static Var prodtotal: Number = 0;
Public static function doprint (datap: object, Title: String, columns: array): void {
VaR printjob: flexprintjob = new flexprintjob ();
If (printjob. Start ()){
VaR theprintview: formprintview = new formprintview ();
Application. application. addchild (theprintview );
Theprintview. reporttitle = title;
Theprintview. datetime = mx. Controls. datefield. datetostring (new date (), "Mm DD, YYYY ");
Theprintview. printdatagrid. Columns = columns;
Theprintview. width = printjob. pagewidth;
Theprintview. Height = printjob. pageheight;
Theprintview. prodtotal = (datap as arraycollection). length;
Theprintview. printdatagrid. dataprovider = datap; // Set Data V
Theprintview. showpage ("single ");
If (! Theprintview. printdatagrid. validnextpage ){
Printjob. addobject (theprintview );
}
Else {
Theprintview. showpage ("first ");
Printjob. addobject (theprintview );
Theprintview. pagenumber ++;
While (true ){
Theprintview. printdatagrid. nextpage ();
Theprintview. showpage ("last ");
If (! Theprintview. printdatagrid. validnextpage ){
Printjob. addobject (theprintview );
Break;
}
Else {
Theprintview. showpage ("Middle ");
Printjob. addobject (theprintview );
Theprintview. pagenumber ++;
}
}
}
Application. application. removechild (theprintview );
}
Printjob. Send ();
}
Private function showpage (pagetype: string): void {
If (pagetype = "first" | pagetype = "Middle "){
Footer. includeinlayout = false;
Footer. Visible = false;
}
If (pagetype = "Middle" | pagetype = "last "){
Header. includeinlayout = false;
Header. Visible = false;
}
If (pagetype = "last "){
// Show the footer.
Footer. includeinlayout = true;
Footer. Visible = true;
}
// Update the DataGrid layout to reflect the results.
Validatenow ();
}
]>
</MX: SCRIPT>
<! -- The template for the printed page, with the contents for all pages. -->
<Mx: vbox width = "100%" horizontalalign = "Left">
<Mx: Label text = "Page {pagenumber}" color = "# 9e9e9e"/>
<Mx: Label id = "Header" text = "{reporttitle}" fontweight = "bold" fontsize = "21" textalign = "center" width = "100%"/>
<Mx: hrule width = "100%" Height = "1" strokecolor = "#000000"/>
</MX: vbox>
<Mx: printdatagrid id = "printdatagrid" width = "100%" Height = "100%" fontfamily = "simsun" fontsize = "12"/>
<Mx: vbox width = "100%" horizontalalign = "Left" id = "footer">
<Mx: Spacer Height = "100%"/>
<Mx: hrule width = "100%" Height = "1" strokecolor = "#000000"/>
<Mx: hbox width = "100%">
<Mx: Label text = "Total record count: {prodtotal}"/>
<Mx: Spacer width = "100%"/>
<Mx: Label text = "print date: {datetime}"/>
</MX: hbox>
</MX: vbox>
</MX: vbox>