Download the PHP package alexallotment/laravel-google-cloud-print without Composer
On this page you can find all versions of the php package alexallotment/laravel-google-cloud-print. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alexallotment/laravel-google-cloud-print
More information about alexallotment/laravel-google-cloud-print
Files in alexallotment/laravel-google-cloud-print
Package laravel-google-cloud-print
Short Description Google Cloud Print Service Provider for Laravel 5
License MIT
Informations about the package laravel-google-cloud-print
Google Cloud Print service for Laravel 6
Install
Via composer :
composer require gnurlan/laravel-google-cloud-print
Then add the service provider class to your Laravel config/app.php
:
'providers' => [
// ...
Bnb\GoogleCloudPrint\LaravelServiceProvider::class,
// ...
],
Also add the Facade alias if you intend to use it :
'aliases' => [
// ...
'GoogleCloudPrint' => Bnb\GoogleCloudPrint\Facades\GoogleCloudPrint::class,
// ...
],
Configuration
Set the env parameter GCP_CREDENTIALS_PATH
to the absolute path
(or relative to the laravel application root) of the servie account
JSON file downloaded from Google Console.
Google service setup
Create a service account key (IAM) with a ***@re-speedy-diagnostic.iam.gserviceaccount.com
and download the JSON key file at https://console.developers.google.com/apis/credentials.
Copy the file into the project at the configured env path.
You also need to allow print access to the generated email address on all the desired printers via the Google Cloud Print console at https://www.google.com/cloudprint/#printers.
This library will attempt to accept the invite if the Google API rejects the credentials. Indeed Google service accounts do not get the invitation email with the accept link and therefore need to use the API to complete the process.
Usage
Create a print task
Either use the Facade or the shortcut with one of the three provided content type to get a print task object :
Configure and send the print task
Calling ->printer($printerId)
is required. The $printerId
is the
printer's UUID you get on the printer details page at Google Cloud Print
console (or in the printer URL).
The content can be provided in three way :
- raw via
->content('A raw content')
. - local file via
->file('/path/to/my/file')
. An exception is thrown if the file is not accessible - url via
->url('http://acme.foo/bar')
. The content is downloaded locally before sending the print job. An exception is thrown if the URL does not begin withhttp(s)://
You can set any other Cloud Job Ticket option via the ->ticket($key, $value)
method.
Some helpers are provided :
- range helper via
->range($start, $end)
(start and end pages are included). - margins helpers via the
->marginsInMillimeters($top, $right, $bottom, $left)
and->marginsInCentimeters($top, $right, $bottom, $left)
.
If the job is rejected an exception is thrown.
Examples
All versions of laravel-google-cloud-print with dependencies
illuminate/config Version 5.x
illuminate/session Version 5.x
illuminate/support Version 5.x
google/apiclient Version ^2.1