【发布时间】:2013-05-15 09:21:32
【问题描述】:
我正在使用 Cordova 构建应用程序,并使用此插件打印 HTML 页面的内容。我会尝试将其打印为 PDF,而不是使用 AirPrint 打印机。 我该怎么做(也可以通过修改插件文件夹中的 .m 和 .h 文件)? 这是我用过的插件:https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/PrintPlugin 谢谢!
var html = document.getElementById("printHTML").innerHTML;
window.plugins.printPlugin.print(
html,
function(result) {
alert("Printing successful");
},
function(result) {
if (!result.available){
alert("Printing is not available");
}
else{
//Localised error description
alert(result.error);
}
});
【问题讨论】:
-
iOS 中没有 PDF 打印机,您提供的插件只允许打印到 AirPrinter。在本机代码中,您可以访问
UIKitUIGraphicsBeginPDFContextToData: developer.apple.com/library/ios/#documentation/2ddrawing/…
标签: ios objective-c cordova