How to Automate Printing
From Your Website
Using the Google Cloud Printing Service
We're making business easy...
This article is directed towards those that are looking to expand the label printing capabilites of their online store or website. We will explain how you can use a form on your website to automate your label/invoice printing with only a printer and an internet connection.
With Automated Printing via the Cloud
Being able to automate the printing of labels, barcodes, PDF's or any user response from your website is a feauture that should be relatively easy with all the advancements in Computer and Software technology. Unfortuantely this isn't the case, it's time consuming, difficult and you need to build your own workaround solution, so we've done it for you. With the help of Google Cloud's print service and integrations with mPDF, IFTTT and Wappwolf, you can streamline your workflow to automatically receive print documents and send them to print automatically.
In this tutorial we will show you how you can automate the printing of a HTML document, which is converted to a pdf and saved in your directory prior to printing.
You will need to use the google cloud print service knowledgebase for assistance with this tutorial:
What you need before proceeding:
- Intermediate/advanced programming knowledge to build and manipulate SQL database table and integrate php library..
- Google+ account (google account with a gmail address)
- Google Cloud Ready printer (or connect printer directly to a pc/router)
- Google Chrome installed
- mPDF(mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML) -
- Wappwolf account -
- IFTTT account -
What are the steps:
- Setup Google Cloud Print API
- Setup Gmail and Google Drive
- Create sql database and table
- Install mPDF to server
- Create IFTTT and Wappwolf integrations
- Setup form and handling php file to smtp to your Gmail account
- Process user response into formatted PDF for print
- Integrations automate google cloud print service when document is received.
Setting up your Google Cloud Print API
- Simply navigate to https://www.google.com/cloudprint/ and login or create a new google+ account.
- On the left hand side of the landing page you should find and click-on 'add a cloud-ready printer'.
- Once the printer has been setup you can find your printer details by clicking on 'printers'.
Setup Gmail and Google Drive
- Navigate to https://accounts.google.com/SignUp?hl=en
- After you have created your Google+ account you will be able to create your 'Google Drive'.
Setup form and handling php file to smtp to your Gmail account
After you have created your sql database you will need to add a database user with full priveleges, we will then setup a form and submit a user response from the website to be automatically printed.
Simply, setup a form on your html page like the one below and submit that form to the server (process the form response with a php handler). This is where you will need to create the sql database table and use smtp settings to post the user's input through an email to the server. You can modify the below HTML code to for a standard form submitting to the server:
First you will need to create a page where you can place html code:
Initiating a Post to the Database
Next you will create an Ajax POST to transfer the input from the user for server sider processing.
Creating the PHP Handling File
Next you will need to create a php file to handle the data from the Ajax Post. We have called it processData.php to place our php.
This is the data submitted by the user
Invoice Date: '.$today.'
Creating a Thankyou Page
Now you will need to create a thankyou page to let the user know the form has been submitted to the google drive.
Thank you page after posting user respone/h1>
If you have setup sendtoprint.php and your Wappwolf and IFFT integrations properly you should expect your pdf to print soon.
Now to create sendToPrint.php:
Now that we have processed the user response, we will need to create another php file called sendToPrint.php.
This php file will handle the pdf we have created and smtp it to your email address.
*Make sure you have the phpmailer class installed on your server.
You will also need to create a mail account on your server so you can smtp the .pdf to your email address.
*This is where you will need to have created your Google+ account so your gmail account can receive the .pdf.
Setting up the IFTTT and Wappwolf Integrations
Now that all the hard work is done, we simply need to setup our integrations with IFTTT and Wappwolf then you have successfully setup your automated printing from your website.
All you need to do is create a free account with IFTTT on https://ifttt.com/join
The next step is to turn on the applet "Automatically save new email attachments in Gmail to Google Drive" , found at https://ifttt.com/applets/99068p-automatically-save-new-email-attachments-in-gmail-to-google-drive, you can filter messages like this and add a label, or if it hasn'y done this automatically, label all message received like this as 'PDF to Print'.
The next step is to setup Wappolf's integration which will detect new attachments which arrive in your google drive from the IFTTT integration and automate your Google Cloud Printing. If you have created an account, navigate to http://wappwolf.com/gdriveautomator and set up the integration to automate your google drive to print and new attachments received to your google drive with the label PDF to Print.
Now the you have made it to the bottom, you should have setup
your automated printing with Google Cloud Print.