airprint
6 人关注该话题
H5或mui有打印控件吗 打印 print airprint
大前端小王子 2019-02-21 11:50 回复问题 • 12 人关注 • 9 个回复 • 19713 次浏览
打印疑问请教 打印 airprint
huyong1978 2015-07-05 11:55 回复问题 • 5 人关注 • 5 个回复 • 3649 次浏览
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");
}
```