Printing From a Raspberry Pi

1,780

16

I had a problem with my laptop so I had to rig up my Raspberry Pi 3 as a temporary arrangement. Things went fine until I needed to print documents. I have a wi-fi printer, HP Envy 5540, and spent some time trying to connect it to my Pi using CUPS, the standard method. After an hour or so, I gave up. However, after a break and re-think, I came up with two methods for printing which whilst very obvious now, were not so when I was in the throes of having to print an important document. These are as follows:

1- Setting up my HP Envy as a Google Cloud printer.

2. Emailing my documents to my wi-fi printer.

I will cover both these simple methods and also say a little about my Linux Desktop experience, including setting up a local email server which I could also use to print documents.

BOM

Raspberry Pi 3 - At least 1G Ram

SD Card with Raspbian stretch with Desktop image (Class 10 16gb sd card or above)

Monitor with HDMI connectivity

HDMI cable

USB mouse and keyboard

Wi-fi printer

Step 1: Setting Up the Linux Desktop ( and Some Lessons From This Experience)

Firstly, I downloaded the Raspbian stretch with Desktop image from the Raspberry Pi web site and burned it onto a 16G sd card. I connected my Pi v3 to an old TV monitor I had using a HDMI cable. I also connected a USB mouse and keyboard to my mouse. I used primarily the Libre Office suite which comes bundled with the Raspbian stretch image. In other words, my primary need was to do some basic word processing on the Pi, and as I said at the start, my challenge was printing documents.

As someone who faithfully uses MS laptops to do my office work and Linux servers for back end processing, I was pleasantly surprised. I want to mention a number of Linux features which I think Windows lacks.

1. Remote file transfer between my Pi and Web server (or other Linux devices)

In simple terms, you can use SCP from the Pi terminal which may be accessed from the icon top left icon >_

The syntax is as follows

scp file user@remote_ip_address:/folder_location

e.g.

scp test.txt james@192.168.1.1:/var/www/html (remote apache web server home directory)

You are prompted for the user password which is of course a good security feature. However, if you want to run SCP without a password prompt, e.g. for repetive tasks then you need to setup key-based authentication. This is well documented on the web.

2. Time delayed Screen capture

Scrot may be used for this and here is a simple example which you run from the command line:

scrot -d 10 /home/pi/pictures/name.png (delay of 10 seconds - where pictures is the folder to send the screenshot to and name is the name you give the screenshot).

3. Other system utilities

I installed VNC server for remote access and also used Cron to schedule back-ups, transfers etc.

Step 2: Printing by Email and Cloud Printing

1. Email printing -

I am not trying to push HP wi-fi subscription printing services. I just wanted to maximise what I have available.

If you subscribe to this service, you will receive an email from HP titled - HP Instant Ink billing statement. If you look in the body of the email you will see details on your printer model and an associated email address -

e.g. Re: Printer model: ENVY 5540 All-in-One Printer series Printer email: yourdeviceid@hpeprint.com

You can use your usual email client to send your document as an attachment to the printer email address and it will print. Unfortunately, it also prints the body and subject of the email, but on the other hand, I had no problems sending MS office documents wirelessly to the printer.

2. Google Cloud Printer

I also set up my printer as a cloud printer through Google Drive. The steps are to select the print option when you open a document and look for the Google Cloud Print Manage option and then select your printer type. The disadvantage is that you have to copy and paste your document into Google docs format which I found restrictive.

The other advantage is that if you are using the Chromium browser ( in my case, Version 60.0.3112.89 (Developer Build) Built on Ubuntu 14.04, running on Raspbian 9.1 (32-bit)) then you can print through Google Cloud printers. All you do in the browser is select print, select change destination and then go to the Google Cloud Print Manage option.

3. Other Options if you have more time

3.1. CUPS

People will tell you to use CUPS but I couldn't find the driver for my printer and hadn't time to problem solve it.

3.2. SSMTP

For the more ambitious, you can set up a simple e-mail server SSMTP on your Pi and print from the command line. The steps are as follows, from the terminal command line:

sudo apt-get install ssmtp
sudo apt-get install mailutils

Note, that this Pi image does not have send mail installed and therefore you don't have the hassle of uninstalling it first.

Now edit the SSMTP configuration file
sudo nano /etc/ssmtp/ssmtp.conf

It needs to include this:

root=postmaster

mailhub=smtp.gmail.com:587

rewriteDomain=gmail.com

hostname=raspberrypi

AuthUser=AGmailUserName@gmail.com

AuthPass=TheGmailPassword

FromLineOverride=YES

UseSTARTTLS=YES

Mime-Version: 1.0

Content-type: text/html;

charset="iso-8859-1"

Save and exit

Sending an email
echo "Hello world email body" | mail -s "Test Subject" recipientname@domain.com

Sending A File Install mpack

sudo apt-get install mpack To send a file

mpack -s "Test" /home/pi/some_folder/somefile.ext recipientname@domain.com

3.3 Sensible-lomua

It would be very useful if you could print to the wireless printer by sending an email from Libre Office. To do this you can try the difficult job of installing sensible-lomua which has known bugs.

You can also try to print from LibreOffice by mail merge through SSMTP but I don't recommend this as it does not offer TLS.

3.4. Summary

The route you take to print from your Pi depends on the time you have and your printer model. Many report that CUPS works for them but I didn't for me. In the future, after my new Windows 10 laptop arrives, I will consider using my Pi as a back up machine. Indeed, it offers a very good option to those on a low budget or have spares lying around.

Please ensure that you consider security when printing. For example, in the case of setting up SSMTP, using gmail enforces the use of TLS for secure transmission but you will have to leave your gmail credentials in clear text on your Pi. To counter this, you need to restrict access to your Pi by not using default passwords and keeping your device physically secure, etc etc etc.

Of course, you can use Office 365 to deliver printing needs but as I write this, I haven't taken out the required subscription.

Share

    Recommendations

    • Plastics Contest

      Plastics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Optics Contest

      Optics Contest

    Discussions