This page was saved using jaction on 2006-09-04 8:33:41.
Address: http://flexdocs.kr/docs/flex2/langref/mx/printing/FlexPrintJob.html
Title: mx.printing.FlexPrintJob (Flex™ 2 레퍼런스 가이드)  •  Size: 36494
Packagemx.printing
Classpublic class FlexPrintJob
InheritanceFlexPrintJob Inheritance Object

FlexPrintJob 클래스는, Flash Player 의 PrintJob API 에 대한 래퍼입니다. 복수 페이지에 출력하는 경우의 자동적인 슬라이스와 페이지 배치, 및 프린터의 페이지 크기에 맞춘 grid 컨텐츠의 신축을 지원(support)합니다.

View the examples



Public property
 property정의
 Inheritedconstructor : Object
특정의 object 인스턴스의 클래스 object 또는 constructor    함수에의 참조입니다.
Object
  pageHeight : Number
[read-only] 프린터 페이지의 인쇄 가능 area의 높이. 유저가 설정한 margin는 포함되지 않습니다.
FlexPrintJob
  pageWidth : Number
[read-only] 프린터 페이지의 인쇄 가능 area의 폭. 유저가 설정한 margin는 포함되지 않습니다.
FlexPrintJob
  printAsBitmap : Boolean
작업 컨텐츠를 비트 맵으로서 인쇄하는지 (true), 벡터 형식에서 인쇄하는지 (false)를 지정합니다.
FlexPrintJob
 Inheritedprototype : Object
[static] 클래스 또는 함수 object의 prototype object에의 참조입니다.
Object
Public Methods
 Methods정의
  FlexPrintJob ()
constructor   .
FlexPrintJob
  addObject (obj:IUIComponent , scaleType:String = "matchWidth"):void
인쇄하는 object의 리스트에 UIComponent object를 추가합니다.
FlexPrintJob
 InheritedhasOwnProperty (name:String ):Boolean
object로 지정된 property가 정의되고 있는지 어떤지를 나타냅니다.
Object
 InheritedisPrototypeOf (theClass:Object ):Boolean
Object 클래스의 인스턴스가, Parameters로서 지정된 object의 prototype 체인내에 있을지 어떨지를 나타냅니다.
Object
 InheritedpropertyIsEnumerable (name:String ):Boolean
지정된 property가 존재해, 열거 가능한가 어떤가를 나타냅니다.
Object
  send ():void
인쇄를 개시하기 위해서, 추가된 object를 프린터에 송신합니다.
FlexPrintJob
 InheritedsetPropertyIsEnumerable (name:String , isEnum:Boolean = true):void
루프 처리에 대한 다이나믹 property의 가용성을 설정합니다.
Object
  start ():Boolean
PrintJob object를 초기화합니다.
FlexPrintJob
 InheritedtoString ():String
지정된 object의 string 표현을 돌려줍니다.
Object
 InheritedvalueOf ():Object
지정된 object의 원시적치를 돌려줍니다.
Object
property의 상세
pageHeightproperty
pageHeight:Number   [read-only]

프린터 페이지의 인쇄 가능 area의 높이. 유저가 설정한 margin는 포함되지 않습니다. start() Methods로부터 돌아간 후로 설정합니다.

Implements
    public function get pageHeight():Number
pageWidthproperty 
pageWidth:Number   [read-only]

프린터 페이지의 인쇄 가능 area의 폭. 유저가 설정한 margin는 포함되지 않습니다. 이 property는,start() Methods가 결과를 돌려준 후로 설정됩니다.

Implements
    public function get pageWidth():Number
printAsBitmapproperty 
printAsBitmap:Boolean   [read-write]

작업 컨텐츠를 비트 맵으로서 인쇄하는지 (true), 벡터 형식에서 인쇄하는지 (false)를 지정합니다. 비트 맵으로서 인쇄하면, 출력에 알파 투명도 또는 칼라 effect를 사용한 비트 맵 이미지를 포함할 수가 있습니다. 컨텐츠에 알파 투명도 또는 칼라 effect를 사용한 비트 맵 이미지가 포함되지 않는 경우는,printAsBitmap property를 false 로 설정하면, 보다 고품질의 벡터 형식에서 인쇄할 수 있습니다.

디폴트치true.

Implements
    public function get printAsBitmap():Boolean
    public function set printAsBitmap(value:Boolean ):void
constructor    의 상세
FlexPrintJob()constructor   
public 함수 FlexPrintJob()

constructor   .

Methods의 상세
addObject()Methods
public function addObject(obj:IUIComponent , scaleType:String = "matchWidth"):void

인쇄하는 object의 리스트에 UIComponent object를 추가합니다. start() Methods가 돌려주어진 후에 이 Methods를 호출합니다. 이 Methods가 불려 갈 때마다, 새로운 페이지가 개시됩니다. 그 때문에, object를 페이지 크기의 결정되어에 포맷 설정할 필요가 있습니다. PrintDataGrid 클래스를 사용하면, 데이터 격자를 복수의 페이지에 걸치게 할 수가 있습니다.

Parameters
obj:IUIComponent — 인쇄하는 object.
 
scaleType:String (default = "matchWidth") — 프린트 페이지에 object를 거두는 방법을 제어하기 위해서 사용하는 신축 수법입니다. FlexPrintJobScaleType 클래스에서 정의된 정수치의 어느 쪽인가에 됩니다.

See also

send()Methods 
public function send():void

인쇄를 개시하기 위해서, 추가된 object를 프린터에 송신합니다. addObject() Methods를 사용해 프린트 페이지를 추가한 후에, 이 Methods를 호출합니다.

start()Methods 
public function start():Boolean

PrintJob object를 초기화합니다. operating system의 [프린터] 다이알로그 박스를 유저에게 표시합니다. Flex 는, 이 호출이 돌려주어진 후에 pageWidthpageHeight property를 설정합니다.

반환값
Boolean — [인쇄] 다이알로그 박스로 유저가 [OK] 를 클릭했을 경우는 true, 유저가 [캔슬] 을 클릭했을 경우, 또는 에러가 발생했을 경우는 false 를 돌려줍니다.
Examples
FormPrintHeader
<? xml version="1.0"? >
<! -- Custom control for the header area of the printed page.  -->

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="60%"
    horizontalAlign="right" >

    <mx:Label text="This is a placeholder for first page contents"/>
</mx:VBox>
FormPrintFooter
<? xml version="1.0"? >
<! -- Custom control for the footer area of the printed page.  -->

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="60%"
    horizontalAlign="right" >
    <! -- Declare and initialize the product total variable.  -->

    <mx:Script>
        <! [CDATA[
            [Bindable]
            public var pTotal:Number = 0;
        ]]>
    </mx:Script>
    <mx:Label text="Product Total: {pTotal}"/>
</mx:VBox>
FormPrintView
<? xml version="1.0"? >
<! -- Custom control to print the DataGrid control on multiple pages.  -->

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" backgroundColor="#FFFFFF"
    paddingTop="50" paddingBottom="50" paddingLeft="50">

    <mx:Script>
        <! [CDATA[
            import mx.core. *
            // Declare and initialize the variables used in the component.
            // The application sets the actual prodTotal value.
            [Bindable]
            public var pageNumber:Number = 1;
            [Bindable]
            public var prodTotal:Number = 0;

            // Control the page contents by selectively hiding the header and
            // footer based on the page type.
            public function showPage(pageType:String) :void {
                if(pageType == "first" || pageType == "middle") {
                    // Hide the footer.
                    footer.includeInLayout=false;
                    footer.visible = false;
                }
                if(pageType == "middle" || pageType == "last") {
                    // The header won't be used again; hide it.
                    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="80%" horizontalAlign="left">
        <mx:Label text="Page {pageNumber}"/>
    </mx:VBox>

    <FormPrintHeader id="header" />
    <! -- The data grid.  The sizeToPage property is true by default, so the last
        page has only as many grid rows as are needed for the data.  -->
    <mx:PrintDataGrid id="myDataGrid" width="60%" height="100%">
    <! -- Specify the columns to ensure that their order is correct.  -->
        <mx:columns>
            <mx:DataGridColumn dataField="Index" />
            <mx:DataGridColumn dataField="Qty" />
        </mx:columns>
    </mx:PrintDataGrid>

    <! -- Create a FormPrintFooter control and set its prodTotal variable.  -->
    <FormPrintFooter id="footer" pTotal="{prodTotal}" />

</mx:VBox>
PrintDataGridExample
<? xml version="1.0"? >
<! -- Main application to print a DataGrid control on multiple pages.  -->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initData();">

    <mx:Script>
        <! [CDATA[

        import mx.printing. *;
        import mx.collections.ArrayCollection;
        import FormPrintView;

        // Declare variables and initialize simple variables.
        [Bindable]
        public var dgProvider:ArrayCollection;
        public var footerHeight:Number = 20;
        public var prodIndex:Number;
        public var prodTotal:Number = 0;
        
        // Data initialization.
        public function initData() :void {
            // Create the data provider for the DataGrid control.
            dgProvider = new ArrayCollection; 
        }
        
        // Fill the dgProvider ArrayCollection with the specified items.
        public function setdgProvider(items:int) :void {    

            prodIndex=1;
            dgProvider.removeAll();
            for (var z:int=0; z<items; z++)    
            {
                var prod1:Object = {};
                prod1.Qty = prodIndex * 7;
                prod1.Index = prodIndex++;
                prodTotal += prod1.Qty; 
                dgProvider.addItem(prod1);
            }
        }

        // The function to print the output.
        public function doPrint() :void {

            var printJob:FlexPrintJob = new FlexPrintJob();
            if (printJob.start()) {
                // Create a FormPrintView control as a child of the current view.
                var thePrintView:FormPrintView = new FormPrintView();
               Application.application.addChild(thePrintView);
                
                //Set the print view properties.
                thePrintView.width=printJob.pageWidth;
                thePrintView.height=printJob.pageHeight;
                thePrintView.prodTotal = prodTotal;
                // Set the data provider of the FormPrintView component's data grid
                // to be the data provider of the displayed data grid.
                thePrintView.myDataGrid.dataProvider = myDataGrid.dataProvider;
                // Create a single-page image.
                thePrintView.showPage("single");
                // If the print image's data grid can hold all the provider's rows, 
                // add the page to the print job.  
                if(! thePrintView.myDataGrid.validNextPage)
                {
                    printJob.addObject(thePrintView);
                }
                // Otherwise, the job requires multiple pages.
                else
                {
                    // Create the first page and add it to the print job.
                    thePrintView.showPage("first");
                    printJob.addObject(thePrintView);
                    thePrintView.pageNumber++;
                    // Loop through the following code until all pages are queued.
                    while(true)
                    {
                        // Move the next page of data to the top of the print grid.
                        thePrintView.myDataGrid.nextPage();
                        thePrintView.showPage("last");    
                        // If the page holds the remaining data, or if the last page 
                        // was completely filled by the last grid data, queue it for printing.
                        // Test if there is data for another PrintDataGrid page.
                        if(! thePrintView.myDataGrid.validNextPage) 
                        {
                            // This is the last page; queue it and exit the print loop.
                            printJob.addObject(thePrintView);
                            break;
                        }
                        else
                        // This is not the last page.  Queue a middle page.  
                        {
                            thePrintView.showPage("middle");
                            printJob.addObject(thePrintView);
                            thePrintView.pageNumber++;
                        }
                    }
                }
                // All pages are queued; remove the FormPrintView control to free memory.
                Application.application.removeChild(thePrintView);
            }
            // Send the job to the printer.
            printJob.send();
        }
        ]]>
    </mx:Script>

    <mx:Panel title="CheckBox Control Example" height="75%" width="75%" 
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">

        <mx:DataGrid id="myDataGrid" dataProvider="{dgProvider}">
            <mx:columns>
                <mx:DataGridColumn dataField="Index"/>
                <mx:DataGridColumn dataField="Qty"/>
            </mx:columns>
        </mx:DataGrid>

        <mx:Text width="100%" color="blue"
            text="Specify the number of lines and click Fill Grid first.  Then you can click Print. "/>

        <mx:TextInput id="dataItems" text="35"/>

        <mx:HBox>
            <mx:Button id="setDP" label="Fill Grid" click="setdgProvider(int(dataItems.text));"/>
            <mx:Button id="printDG" label="Print" click="doPrint();"/>
        </mx:HBox>
    </mx:Panel>
</mx:Application>






 

코멘트가 추가되었을 경우, 메일로 받기. | 코멘트 리포트

현재의 페이지: http://flexdocs.kr/docs/flex2/langref/mx/printing/FlexPrintJob.html