我想要列印的畫面是寬度大於高度的樣式,為了方便使用者不用去
設定印表機為橫向列印,所以我打算自己將畫面旋轉90度後再送到
印表機去列印。
目前使用FlexPrintJob,以及設定FlexPrintJobScaleType.SHOW_ALL
要將輸出的畫面佔滿整張A4。但是結果卻是若不旋轉,則畫面會放大到
A4能容納的範圍,若旋轉90度後,畫面卻沒有放大到A4的範圍,不知道
是哪邊沒有處理好,煩請各位前輩指點迷津 謝謝 ^^
範例檔 http://140.136.149.89/PrintTest/PrintTest.swf
(可按右鍵view source, 最好使用Fineprint等軟體來預覽列印結果,節省紙張)
部分程式碼如下
private function print(rotate:Boolean = false):void{
var printJob:FlexPrintJob = new FlexPrintJob();
//旋轉會造成中文字消失,因此先將畫面擷取下來後再旋轉
var bitMap:Bitmap;
var bitMapData:BitmapData;
var img:Image = new Image();
//透過ImageSnapshot把我要列印的畫面抓下來
bitMapData = ImageSnapshot.captureBitmapData(myPanel);
bitMap = new Bitmap(bitMapData);
//設定位移與旋轉角度
var matrix:Matrix = new Matrix();
if (rotate){
matrix.translate(0,-bitMap.height);
matrix.rotate(2 * Math.PI * (90 / 360));
}
img.source = bitMap;
img.width = bitMap.width;
img.height = bitMap.height;
img.scaleContent = true;
img.transform.matrix = matrix;
this.addChild(img);
printJob.start();
printJob.addObject(img, FlexPrintJobScaleType.SHOW_ALL);
printJob.send();
this.removeChild(img);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.117.168