inquid / yii2-inquid-google-print
Print documents and views using Google Cloud Print service.
Installs: 592
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
This package is auto-updated.
Last update: 2024-10-29 05:28:18 UTC
README
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.
Yii2 Google Cloud Print
Print documents and views using Google Cloud Print service.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist inquid/yii2-inquid-google-print "*"
or add
"inquid/yii2-inquid-google-print": "*"
to the require section of your composer.json
file.
Configuration
//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',
],
Usage
Once the extension is installed, simply use it in your code by :
/* 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!"; }
AUTHORIZED REDIRECT URI
For use with requests from web server: http://yourdomain.com?r=googlecloudauth or pretty URL http://yourdomain.com/googlecloudauth/
LOGOUT LINK
if use online token you can logout by URL: http://yourdomain.com?r=googlecloudauth/remove or pretty URL http://yourdomain.com/googlecloudauth/remove