Google has many amazing services and today i have chosen Google cloud printing its a really amazing service for offices to manage there printings etc. You have to set a printer with a computer and connect it with Google cloud printer and use this library on you web so any one can easily print from that website by uploading a file.
index.php it require you Google email address and password to authenticate your account.
$gcp = new GoogleCloudPrint();
$printers = $gcp->getPrinters();
$printerid = "";
$content = "Could not get printers";
$printerid = $printers['id'];
$resarray = $gcp->sendPrintToPrinter($printerid, "Printing Doc using Google Cloud Printing", "upload/" . $_FILES["upload"]["name"], "application/pdf");
$content = "Document has been sent to printer and should print shortly.";
$content = "An error occured while printing the doc. Error code:".$resarray['errorcode']." Message:".$resarray['errormessage'];
Call List of Printers
// Make Http call to get printers added by user to Google Cloud Print
$responsedata = $this->makeHttpCall(self::PRINTERS_SEARCH_URL,array(),$authheaders);
$printers = json_decode($responsedata);
Send file to printer for print
$post_fields = array(
'printerid' => $printerid,
'title' => $printjobtitle,
'contentTransferEncoding' => 'base64',
'content' => base64_encode($contents), // encode file content as base64
'contentType' => $contenttype
// Prepare authorization headers
$authheaders = array(
"Authorization: GoogleLogin auth=" . $this->authtoken
// Make http call for sending print Job
$response = json_decode($this->makeHttpCall(self::PRINT_URL,$post_fields,$authheaders));
// Has document been successfully sent?
return array('status' =>true,'errorcode' =>'','errormessage'=>"");
f you have any problem in using this code please write in comments and need your feedback.