1
赞同来自: wangzhanghong
下边是个NJS版本的打印示例代码:
```javascript
var UIPrintInteractionController = plus.ios.import('UIPrintInteractionController');
var UIPrintInf... 显示全部 »
```javascript
var UIPrintInteractionController = plus.ios.import('UIPrintInteractionController');
var UIPrintInf... 显示全部 »
下边是个NJS版本的打印示例代码:
```javascript
var UIPrintInteractionController = plus.ios.import('UIPrintInteractionController');
var UIPrintInfo = plus.ios.import("UIPrintInfo");
var NSURL = plus.ios.import("NSURL");
//url字符串仅仅用来示例,可以使用plus.io获取
var url = NSURL.fileURLWithPath(plus.io.convertLocalFileSystemURL("_www/img/dcloud.png"));
if ( UIPrintInteractionController.canPrintURL(url) ){
var printInfo = UIPrintInfo.printInfo();
printInfo.setJobName("dcloud.png");
printInfo.setOutputType(1);
var printInteractionController = UIPrintInteractionController.sharedPrintController()
printInteractionController.setPrintInfo(printInfo);
printInteractionController.setShowsNumberOfCopies(false);
printInteractionController.setPrintingItem(url);
printInteractionController.presentAnimatedcompletionHandler(true, null);
} else {
alert("not support");
}
```
```javascript
var UIPrintInteractionController = plus.ios.import('UIPrintInteractionController');
var UIPrintInfo = plus.ios.import("UIPrintInfo");
var NSURL = plus.ios.import("NSURL");
//url字符串仅仅用来示例,可以使用plus.io获取
var url = NSURL.fileURLWithPath(plus.io.convertLocalFileSystemURL("_www/img/dcloud.png"));
if ( UIPrintInteractionController.canPrintURL(url) ){
var printInfo = UIPrintInfo.printInfo();
printInfo.setJobName("dcloud.png");
printInfo.setOutputType(1);
var printInteractionController = UIPrintInteractionController.sharedPrintController()
printInteractionController.setPrintInfo(printInfo);
printInteractionController.setShowsNumberOfCopies(false);
printInteractionController.setPrintingItem(url);
printInteractionController.presentAnimatedcompletionHandler(true, null);
} else {
alert("not support");
}
```