我正在为沙龙创建AIR应用程序,我想以小页面打印发票。
我怎样才能实现这些?请帮帮我
感谢。
答案 0 :(得分:1)
Web示例可以将其转换为AIR: - 请查找示例dataGrid打印以及如何将其更改为250 * 250。您可以在哪里为打印视图创建自定义组件布局,并在其中包含打印组件。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.printing.*;
// Create a PrintJob instance.
private function doPrint():void {
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start() != true)
return;
myDataGridPrint.height = 250;
myDataGridPrint.width = 250;
myDataGridPrint.dataProvider = myDataGrid.dataProvider;
printJob.addObject(myDataGridPrint, FlexPrintJobScaleType.NONE);
printJob.send();
}
]]>
</fx:Script>
<mx:VBox id="myVBox">
<mx:DataGrid id="myDataGrid" width="300">
<mx:dataProvider>
<fx:Object Product="Flash" Code="1000"/>
<fx:Object Product="Flex" Code="2000"/>
<fx:Object Product="ColdFusion" Code="3000"/>
<fx:Object Product="JRun" Code="4000"/>
</mx:dataProvider>
</mx:DataGrid>
<!--Print Data Grid-->
<mx:DataGrid id="myDataGridPrint" visible="false" includeInLayout="false"/>
<mx:Button id="myButton"
label="Print"
click="doPrint();"/>
</mx:VBox>
</s:Application>
希望这可能有所帮助...