我想使用JavaScript将打印作业发送到Google云打印。
我想要
$.post(api_url, {printerId:1, data:"helloworld"}, function(res){
console.log(res);
})
类似的东西对我有用。但我愿意接受其他选择。与我分享您的经验。谢谢。
答案 0 :(得分:0)
我从Google Cloud Print Developer Page找到了它:
GCP网络元素:
““ Google云打印Web元素是向您的网站或应用程序添加GCP功能的最简单方法。通过内容或URL传递要打印的文档,并获得Google Cloud Print对话框。如果用户尚未登录GCP,则首先要求他们使用自己的Google帐户登录。此元素已针对台式机和移动浏览器进行了优化。”
<div id="print_button_container"></div>
加载您的JS:
<script src="https://www.google.com/cloudprint/client/cpgadget.js"></script>
<script>
window.onload = function() {
var gadget = new cloudprint.Gadget();
gadget.setPrintButton(
cloudprint.Gadget.createDefaultPrintButton("print_button_container"));// div id to contain the button
//Documentation to send:
gadget.setPrintDocument("[document mimetype]", "[document title]", "[document content]", "[encoding] (optional)");
}
</script>
遵循一个示例:
gadget.setPrintDocument("url", "Test Page", "https://www.google.com/landing/cloudprint/testpage.pdf");
我希望它能为您提供帮助。 :)