inquid/yii2-inquid-google-print Print documents and views using Google Cloud Print service.

Yii Framework

Donate

Yii2 Google Cloud Print

  1. Installation
  2. Configuration
  3. Usage
  4. AUTHORIZED REDIRECT URI
  5. LOGOUT LINK
  6. SUPPORT

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

SUPPORT

paypal

0 0
1 follower
372 downloads
Yii Version: 2.0
License: LGPL-3.0+
Category: Web Service
Developed by: Luis Armando
Created on: Mar 23, 2018
Last updated: (not set)
Packagist Profile
Github Repository

Related Extensions