Ultimate Raspberry Pi : LAN Print , Scan and PDF Server : CUPS + AirPrint + IPP + cups-pdf + sanescan ( SaneTwain ) + phpSANE / PHP-Scanner-Server ( scanner webinterface ) + samba ( remote file access )

Assumptions:
Completed Ultimate Raspberry Pi : Preparation and with optional server preparation.
Raspberry pi IP address : 192.168.1.111

Install Dependencies

Optional: Install one of the relevant printer drivers

Configure cups to listen on the LAN

Allow LAN access to CUPS

Add the server name and browse addess
replace 192.168.1.255 with your LAN broadcast address

Restart CUPS

Add the pi user to the lpadmin group

Enable print sharing and remote administration

Custom cups-pdf output directory
PDF storage directory: /storage/pdf

Append the date to the pdf file name and move to PDF storage directory

enable cups-pdf post processing

enable automatic retrying of failed print jobs

Restart CUPS

Configure your Printer

Visit the webinterface: https://192.168.1.111:631/admin/
admin username: pi
admin password: raspberry

Add your printer
Connect your printer to the usb port of the raspberry pi and power the printer on
Navigate to Administration -> Find New Printers
Under Available Printers
Click Add This Printer
The Name, Description and Location should be filled in

Enable: Share This Printer

Click Continue
Select your Make and model from the list of specify a PPD file.
Click Add Printer

Restart CUPS and avahi

Using your PDF postscript printer via IPP

Driver: Microsoft Windows: Manufacturer: “Generic” Printer: “MS Publisher Imagesetter”
Via IPP
The preferred way to connect a Windows client to a Linux print server is using IPP
Use the following as the printers location

http://192.168.1.111:631/printers/PDF

Using your printer via IPP

Driver: Windows 10
Manufacturer: “Generic”
Printer: “MS Publisher Imagesetter”
Driver: Windows Vista and 7/8
Manufacturer: “HP”
Printer: “HP Color Laserjet 8550 PS” or “HP Color Laserjet 4550 PS”
Driver: Windows 2000 and XP
Manufacturer: “HP”
Printer: “HP Color Laserjet PS”
Via IPP
The preferred way to connect a Windows client to a Linux print server is using IPP
Use the following as the printers location

http://192.168.1.111:631/printers/printer_name

Optional: Enable Scanning

Enable scanning support and share a scanner on your network
Install

Enable the saned service

Enable the xinetd sane service

BUG FIX: scanner not working: usbfs: interface 1 claimed by usblp while ‘scanimage’ sets config #1

Reboot

verify the scanner is supported and listening

device `xerox_mfp:libusb:001:004′ is a Samsung Samsung SCX-4623 Series multi-function peripheral

sane-port 6566/tcp sane saned # SANE network scanner daemon

Optional: phpSANE ( Web-Based Frontend for SANE )

Note: Simple and low requirements
Install Requirements

Install phpSANE
http://sourceforge.net/projects/phpsane/

Configure

Set Permissions

Optional: PHP-Scanner-Server ( Very advanced Web-Based Frontend for SANE )

NOTE: will require 1GB+ drive space and a 512MB pi.
Install Requirements

Add www-data to the lp group

Install phpSANE
https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server

Configure

Create Directories and Set Permissions

Configure

Configure via the web interface
Visit: http://192.168.1.111/scanner/index.php?page=Config

Using your scanner

Windows users use TWAIN drivers, which will create a bridge between TWAIN and SANE on the network.
Download the windows installer : http://sanetwain.ozuzo.net/downloads/setup136.exe

http://sanetwain.ozuzo.net/#download

Windows 7 / 8 Support

Navigate to “C:Program Files (x86)SaneTwain”
Right click “ScanImage.exe” and select Properties
Compatibility Tab
Tick: Run this program in compatibility mode for: Windows XP (Service Pack 3)

Launch the program “ScanImage”

Settings -> Connection
Hostname: 192.168.1.111
Port: 6566
Username: PCUSER
tick: Get list of devices on startup
Click ok.

Optional: Enable Samba

We will create a print PDF share and a Scanner share
Install

Configure

Restart samba

Optional: rpisysinfoscript ( Web-Based System Information Frontend)

Visit the webinterface: http://192.168.1.111/sysinfo.php
Install Requirements

Install rpisysinfoscript

CUPS Command line utilities

Short Descriptions

accept
instructs the printing system to accept print jobs to the specified destinations.
cancel
cancels existing print jobs from the print queues.
cupsaddsmb
exports printers to the Samba software for use with Windows clients.
cups-config
is a Cups program configuration utility.
cupsctl
updates or queries the cupsd.conf file for a server.
cupsd
is the scheduler for the Common Unix Printing System.
cupsfilter
is a front-end to the Cups filter subsystem which allows you to convert a file to a specific format.
cupstestdsc
tests the conformance of PostScript files.
cupstestppd
tests the conformance of PPD files.
ippfind
finds internet printing protocol printers.
ipptool
sends IPP requests to the specified URI and tests and/or displays the results.
lp
submits files for printing or alters a pending job.
lpadmin
configures printer and class queues provided by Cups.
lpc
provides limited control over printer and class queues provided by Cups.
lpinfo
lists the available devices or drivers known to the Cups server.
lpmove
moves the specified job to a new destination.
lpoptions
displays or sets printer options and defaults.
lppasswd
adds, changes or deletes passwords in the Cups digest password file passwd.md5.
lpq
shows the current print queue status on the named printer.
lpr
submits files for printing.
lprm
cancels print jobs that have been queued for printing.
lpstat
displays status information about the current classes, jobs, and printers.
ppdc
compiles PPDC source files into one or more PPD files.
ppdhtml
reads a driver information file and produces a HTML summary page that lists all of the drivers in a file and the supported options.
ppdi
imports one or more PPD files into a PPD compiler source file.
ppdmerge
merges two or more PPD files into a single, multi-language PPD file.
ppdpo
extracts UI strings from PPDC source files and updates either a GNU gettext or Mac OS X strings format message catalog source file for translation.
reject
instructs the printing system to reject print jobs to the specified destinations.
libcups.so
contains the Cups API functions.

18 replies
  1. avilleret
    avilleret says:

    Thanks for this tutorial !

    Since the RPi is not so much powerful, it may take a long to process page even more if there are pictures or rasterised text.

    One solution for this is using a RAW queue on the CUPS server side and process the file to print on the client side.

    I can do that with my Windows client (sic) but not with Ubuntu.

    Do you know how to setup a RAW queue and use the Ubuntu client’s driver to process file then send those to RPi for direct printing ?

    best

    a

    Reply
  2. BH
    BH says:

    This solved an issue with permissions phpsane had on my system:

    root@raspberry:/var/www# chgrp www-data tmp output/ scanners/

    Reply
  3. Antoine
    Antoine says:

    hello , thanks for this tutorial, please let me show you to this great PHP Scanner Server : https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server.git It’s a lot more powerful and beautiful than PHPSane. Cheers a

    Reply
  4. Jari
    Jari says:

    Dear admin,

    I’m unable to get the Postprocessing script to work. I have tried other scripts, that simply write some text to a file. However, it seems like the script is never actually called. The PDF-output files are created in the /var/spool/cups-pdf/ANONYMOUS correctly, but are not processed any further.

    Do you have any suggestions?

    Regards,

    Jari

    Reply
  5. Are S
    Are S says:

    Hi Admin

    You had a awesome tutorial for optimizing Raspberry, but I cant seem to find it anymore. It worked very well. Is this tutorial somewhere to be found?

     

    Regards

    Are S

    Reply
  6. Erik
    Erik says:

    Great tutorial! For the latest Jessie Apache version, pages are expected in the /var/www/html directory. If your setup is followed, they don’t get served and you see only a 404. Applies as well to the sysinfo.php.

    Also, using not only useradd www-data lp, but also useradd www-data scanner resolves the permission issues.

    PS: Still busy writing the updated Raspberry optimization article? Would love to see it!

    Reply
  7. Phillip
    Phillip says:

    Hi,

    Awesome tutorial, but could I query the “Allow LAN access to CUPS” section, the code of sed i “s||Allow alln|g” /etc/cups/cupsd.conf fails for me, it seems that the regex is missing what it’s to replace with “Allow alln” ?

    Reply
  8. Bassebus
    Bassebus says:

    When printing from iphone/ios, to cups-pdf, documents get’s treated as “ANONYMOUS”. (They are stored in the ‘AnonDirName’ directory in the config).

    It seems like the POSTPROCESSING-script doesnt run then?

    Reply
  9. brain_recall
    brain_recall says:

    I have phpSANE working mostly, but I’m running into one issue I can’t seem to resolve.

    I want to change the output directory of phpSANE to store on my NAS drive directly, so I changed the output directory in config.php to my auto-mounted network share (mounted in fstab). However, the output doesn’t appear in that folder. phpSANE can view files in that folder, and if I copy the command and run it from the terminal manually, the output will be written. Just phpSANE can’t write to that folder. I’m guessing this is some kind of permission issue; does anyone know what the problem could be?

     

    Otherwise, awesome article!

    Reply
  10. brain_recall
    brain_recall says:

    For now I have a workaround using unison. I created a bash script that runs in loop, every 5 seconds is calls unison between the /var/www/html/output folder and the mounted network share directory. I have the script fire up at reboot with cron. The scans get stored to both the SD card first, unison then copies it over to the NAS. Eventually I would delete the scan from the NAS, which unison would delete from the SD card. It’s a hack that I’m happy to live with.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *