top of page
Writer's pictureJLCodE Team

GoogleCloudPrint with Laravel


Hello Everyone.


We know well about Google Cloud APIs - Google Cloud Doc, Google Cloud SQL, Google Cloud VM Instace, Google Cloud Print, etc.


Today, I am going to write some our experiences with Google Cloud Print and

Laravel.


To use Google Cloud Print APIs, you must install necessary package.


Package name : GoogleCloudPrint.

Command : composer require bnbwebexpertise/laravel-google-cloud-print

Download google service account credential : credential.json


Example:

{ "type""service_account", "project_id""cloud-printer-****", "private_key_id""123123123123", "private_key""-----BEGIN PRIVATE KEY----- *****\n-----END PRIVATE KEY-----\n", "client_email"example@cloud-printer-**.iam.gserviceaccount.com", "client_id""123123123123", "auth_uri""https://accounts.google.com/o/oauth2/auth", "token_uri""https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url""https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url""example.gserviceaccount.com"   }


After install package, you can use Class GoogleCloudPrint in necessary php files.

In env file, Add this line. GCP_CREDENTIALS_PATH=./cloudprint.json


Google Cloud Print have some features which can bu used to print from PDF, HTML, Image.


Here, we mention about from PDF.


Before run print function, you need to create PDF file what you want to print.


GoogleCloudPrint::asPdf()                     ->file($path.$filename.'.pdf')                     ->printer($printerId)                     ->send();


After execute print function, you can see the pdf file in google printer page under you selected printer ID.


That's all.

Hope this will be helpful.

 

Next time, we'll post some technologies in Mobile Hybrid application (CMS CRUD).

Thanks a lot.

JLCode






7 views

Comments


bottom of page