| パッケージ | mx.printing |
| public class FlexPrintJob | |
| 継承 | FlexPrintJob Object |
関連項目
| プロパティ | 定義 | ||
|---|---|---|---|
![]() | constructor : Object
指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクタ関数への参照です。
| Object | |
| pageHeight : Number
[read-only]
プリンタページの印刷可能領域の高さ。ユーザーが設定した余白は含まれません。
| FlexPrintJob | ||
| pageWidth : Number
[read-only]
プリンタページの印刷可能領域の幅。ユーザーが設定した余白は含まれません。
| FlexPrintJob | ||
| printAsBitmap : Boolean
ジョブコンテンツをビットマップとして印刷するか (
true)、ベクター形式で印刷するか (false) を指定します。 | FlexPrintJob | ||
![]() | prototype : Object
[static]
クラスまたは関数オブジェクトのプロトタイプオブジェクトへの参照です。
| Object | |
| メソッド | 定義 | ||
|---|---|---|---|
|
コンストラクタです。
| FlexPrintJob | ||
|
印刷するオブジェクトのリストに UIComponent オブジェクトを追加します。
| FlexPrintJob | ||
![]() |
指定されたプロパティがオブジェクトに定義されているかどうかを示します。
| Object | |
![]() |
Object クラスのインスタンスが、パラメータとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
| Object | |
![]() |
指定されたプロパティが存在し、列挙できるかどうかを示します。
| Object | |
|
印刷を開始するために、追加されたオブジェクトをプリンタに送信します。
| FlexPrintJob | ||
![]() |
ループ処理に対するダイナミックプロパティの可用性を設定します。
| Object | |
|
PrintJob オブジェクトを初期化します。
| FlexPrintJob | ||
![]() |
指定されたオブジェクトのストリング表現を返します。
| Object | |
![]() |
指定されたオブジェクトのプリミティブな値を返します。
| Object | |
| pageHeight | プロパティ |
pageHeight:Number [read-only]プリンタページの印刷可能領域の高さ。ユーザーが設定した余白は含まれません。start() メソッドから返った後に設定します。
実装 public function get pageHeight():Number
| pageWidth | プロパティ |
pageWidth:Number [read-only]
プリンタページの印刷可能領域の幅。ユーザーが設定した余白は含まれません。このプロパティは、start() メソッドが結果を返した後に設定されます。
public function get pageWidth():Number
| printAsBitmap | プロパティ |
printAsBitmap:Boolean [read-write]
ジョブコンテンツをビットマップとして印刷するか (true)、ベクター形式で印刷するか (false) を指定します。ビットマップとして印刷すると、出力にアルファ透明度またはカラーエフェクトを使用したビットマップイメージを含めることができます。コンテンツにアルファ透明度またはカラーエフェクトを使用したビットマップイメージが含まれない場合は、printAsBitmap プロパティを false に設定すると、より高品質のベクター形式で印刷できます。
デフォルト値true.
public function get printAsBitmap():Boolean
public function set printAsBitmap(value:Boolean):void
| FlexPrintJob | () | コンストラクタ |
public 関数 FlexPrintJob()コンストラクタです。
| addObject | () | メソッド |
public function addObject(obj:IUIComponent, scaleType:String = "matchWidth"):void
印刷するオブジェクトのリストに UIComponent オブジェクトを追加します。start() メソッドが返された後にこのメソッドを呼び出します。このメソッドが呼び出されるたびに、新しいページが開始されます。そのため、オブジェクトをページサイズのまとまりにフォーマット設定する必要があります。PrintDataGrid クラスを使用すると、データグリッドを複数のページにまたがらせることができます。
obj:IUIComponent — 印刷するオブジェクト。
|
|
scaleType:String (default = "matchWidth") — プリントページにオブジェクトを収める方法を制御するために使用する伸縮手法です。FlexPrintJobScaleType クラスで定義された定数値のいずれかになります。
|
関連項目
| send | () | メソッド |
public function send():void
印刷を開始するために、追加されたオブジェクトをプリンタに送信します。addObject() メソッドを使ってプリントページを追加した後に、このメソッドを呼び出します。
| start | () | メソッド |
public function start():Boolean
PrintJob オブジェクトを初期化します。オペレーティングシステムの [プリンタ] ダイアログボックスをユーザーに表示します。Flex は、この呼び出しが返された後に pageWidth および pageHeight プロパティを設定します。
Boolean —
[印刷] ダイアログボックスでユーザーが [OK] をクリックした場合は true、ユーザーが [キャンセル] をクリックした場合、またはエラーが発生した場合は false を返します。
|
<?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>
<?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>
<?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.* // このコンポーネントで使用される変数を宣言および初期化します。// アプリケーションが、実際の prodTotal の値を設定します。[Bindable] public var pageNumber:Number = 1; [Bindable] public var prodTotal:Number = 0;
// ページタイプに応じてヘッダーとフッターを選択的に非表示にすることにより、// ページ内容を制御します。 public 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") { // フッターを表示します。 footer.includeInLayout=true; footer.visible = true; } // 結果を反映するように、DataGrid レイアウトを更新します。 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>
<?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;
// 変数を宣言し、簡易変数を初期化します。[Bindable] public var dgProvider:ArrayCollection; public var footerHeight:Number = 20; public var prodIndex:Number; public var prodTotal:Number = 0;
// データを初期化します。 public function initData():void { // DataGrid コントロール用のデータプロバイダを作成します。 dgProvider = new ArrayCollection; }
// dgProvider ArrayCollection に特定の項目を入力します。 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); } }
// 出力をプリントする関数です。 public function doPrint():void {
var printJob:FlexPrintJob = new FlexPrintJob(); if (printJob.start()) { // FormPrintView コントロールを現在のビューの子ビューとして作成します。 var thePrintView:FormPrintView = new FormPrintView(); Application.application.addChild(thePrintView);
// プリントビューのプロパティを設定します。 thePrintView.width=printJob.pageWidth; thePrintView.height=printJob.pageHeight; thePrintView.prodTotal = prodTotal; // FormPrintView コンポーネントのデータグリッドに対するデータプロバイダを、// 表示されたデータグリッドに対するデータプロバイダに設定します。 thePrintView.myDataGrid.dataProvider = myDataGrid.dataProvider; // 単一ページのイメージを作成します。 thePrintView.showPage("single"); // プリントイメージのデータグリッドがプロバイダの行すべてを保持できる場合は、// このページをプリントジョブに追加します。 if(!thePrintView.myDataGrid.validNextPage) { printJob.addObject(thePrintView); } // それ以外の場合、このジョブには複数のページが必要です。 else { // 最初のページを作成し、プリントジョブに追加します。 thePrintView.showPage("first"); printJob.addObject(thePrintView); thePrintView.pageNumber++; // 全ページがキューに入るまで、次のコードをループします。 while(true) { // 次のデータページをプリントグリッドの最上部に移動します。 thePrintView.myDataGrid.nextPage(); thePrintView.showPage("last"); // このページが残りのデータを保持する場合、または最終ページが// 完全に最終グリッドデータで埋められた場合は、プリント用にこのページをキューに入れます。// 別の PrintDataGrid ページのデータがあるかどうかテストします。 if(!thePrintView.myDataGrid.validNextPage) { // 最終ページです。このページをキューに入れ、プリントループを終了します。 printJob.addObject(thePrintView); break; } else // 最終ページではない場合は、中間ページをキューに入れる{ thePrintView.showPage("middle"); printJob.addObject(thePrintView); thePrintView.pageNumber++; } } } // 全ページがキューに入ります。FormPrintView コントロールを削除して、メモリを解放します。Application.application.removeChild(thePrintView); } // このジョブをプリンタに送信します。 printJob.send(); } ]]> </mx:Script>
<mx:Panel title="DataGrid Printing 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>