Reputation: 79
I want to send print jobs to Google Cloud Print with JavaScript.
How i want
$.post(api_url, {printerId:1, data:"helloworld"}, function(res){
console.log(res);
})
Something like that works for me. But i am open to alternatives. Share your experience with me. Thanks.
Upvotes: 0
Views: 1862
Reputation: 349
i found it from Google Cloud Print Developer Page:
GCP Web Element:
"The Google Cloud Print Web Element is the simplest way to add GCP functionality to your web site or application. Pass in a document to print, either by content or by URL, and get a Google Cloud Print dialog. If the user is not logged in to GCP, they are first asked to log in with their Google Account. This element is optimized for both desktop and mobile browsers."
<div id="print_button_container"></div>
Load your 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>
Follow a example:
gadget.setPrintDocument("url", "Test Page", "https://www.google.com/landing/cloudprint/testpage.pdf");
i hope it can help you. :)
Upvotes: 0