dev-master
9999999-devPrint documents and views using Google Cloud Print service.
LGPL-3.0+
The Requires
by Inquid
extension yii2
Print documents and views using Google Cloud Print service.
This project will be archived soon due to the fact that Google Cloud Print is discontinued, please stay tuned for the PrintNode libraries as we use them as an alternative for printing., (*1)
Print documents and views using Google Cloud Print service., (*4)
The preferred way to install this extension is through composer., (*5)
Either run, (*6)
php composer.phar require --prefer-dist inquid/yii2-inquid-google-print "*"
or add, (*7)
"inquid/yii2-inquid-google-print": "*"
to the require section of your composer.json
file., (*8)
//Inquid Components 'GoogleCloudPrint' => [ 'class' => 'inquid\googlecloudprint\GoogleCloudPrint', 'refresh_token' => '', // '' - if don't use refresh token offline, then this field must be empty 'client_id' => '...', 'client_secret' => '...', 'grant_type' => 'refresh_token', 'redirect_uri' =>'http://yourdomain.com/googlecloudauth', // http://yourdomain.com/?r=googlecloudauth 'default_printer_id' => '__google__docs' ], //Inquid controllerMap 'controllerMap' => [ 'googlecloudauth' => 'inquid\googlecloudprint\GooglecloudauthController', ],
Once the extension is installed, simply use it in your code by :, (*9)
/* Check Refresh Token */ Yii::$app->GoogleCloudPrint->checkRefreshTokenSession(Yii::$app->request->getAbsoluteUrl()); /* Get printers as an array */ $printers = Yii::$app->GoogleCloudPrint->getPrinters(); /* Render a GridView with the printers */ echo Yii::$app->GoogleCloudPrint->renderPrinters(); /* print html code */ //Yii::$app->GoogleCloudPrint->sendPrintToPrinterContent("__google__docs", "job3", "<b>boba</b>", "text/html"); /* If default printer is not sent, system will take the default printer in the configuration file */ //$result = Yii::$app->GoogleCloudPrint->sendPrintToPrinterContent("", "job3", "<b>boba</b>", "text/html"); /* Send pdf file to print */ $result = Yii::$app->GoogleCloudPrint->sendFileToPrinter("", "Simple pdf", Yii::getAlias('@vendor').'/inquid/yii2-inquid-google-print/simple.pdf', 'application/pdf'); /* Check if print works */ if (isset($result['status'])) { echo "it works!"; }
For use with requests from web server: http://yourdomain.com?r=googlecloudauth or pretty URL http://yourdomain.com/googlecloudauth/, (*10)
if use online token you can logout by URL: http://yourdomain.com?r=googlecloudauth/remove or pretty URL http://yourdomain.com/googlecloudauth/remove, (*11)
Print documents and views using Google Cloud Print service.
LGPL-3.0+
extension yii2