Flex 4 打印预览

阅读更多

 
	
	
	
		= 1)	
				{		// to add multiple component
					var i : int;
					for ( i = 0; i < arrComponents.length; i++)
					{
						this._printMulipleData = arrComponents[i] as IUIComponent;
						bmpData = new BitmapData(_printMulipleData.width, _printMulipleData.height);					
						bmpData.draw(_printMulipleData);
						
						bmp = new Bitmap(bmpData);
						uIcom = new Canvas();
						
						uIcom.rawChildren.addChild(bmp);
						
						/*
						*	TODO : rather simply assigning dimensions - check for compatibility with Paper Size, too 
						*/
						uIcom.width = bmp.width;
						uIcom.height = bmp.height;
						
						printThisComponent.addElement(uIcom as IVisualElement);
					}
				}
				else
					Alert.show("Print data is not available.");
			}
			
			protected function titlewindow1_closeHandler(event:CloseEvent):void
			{
				// TODO Auto-generated method stub
				printThisComponent.removeAllElements();
				this.removeEventListener(CloseEvent.CLOSE, titlewindow1_closeHandler);
				PopUpManager.removePopUp(this);
			}
			
			protected function onPrintHolderUpdateComplete(event:FlexEvent):void
			{
				
			}

		]]>
	
	
	
		
	
	
		
			
				
					
				
				
					 
					
					
				
				
				
		
	
	

 打印按钮触发的事件函数

 

public function print(obj:UIComponent, printForScorllContent:Boolean=false):void
		{
			if (printPreviewPopUp)
			{
				PopUpManager.removePopUp(printPreviewPopUp);
			}
			printPreviewPopUp = new PrintPreviewPopUp();
			printPreviewPopUp.printScrollContent = printForScorllContent;
			if(printForScorllContent)
			{
				printPreviewPopUp.printTitle = headerLabel;
				printPreviewPopUp.dateDisplayString = dateDisplayString;
			}
			printPreviewPopUp.jurisdictionID =  applicationModel.getJurisdictionId();
			PopUpManager.addPopUp(printPreviewPopUp as IFlexDisplayObject, FlexGlobals.topLevelApplication as DisplayObject, true);
			
			if(obj.height>0 && obj.width>0)
			{
				isPrinting = true;
				printPreviewPopUp.toBePrintData = obj;
				printPreviewPopUp.x = FlexGlobals.topLevelApplication.width/2 - obj.width/2;
				printPreviewPopUp.y = 50; 
				PopUpManager.bringToFront(printPreviewPopUp as IFlexDisplayObject );
				printPreviewPopUp.addEventListener(CloseEvent.CLOSE, onPrintPreviewPopupClosed);
			}
		}

 

 

你可能感兴趣的:(Flex 4 打印预览)