pdf2email is a CUPS backend that uses GhostScript to print a document to PDF and sends the final file to the user that requested the print via email. This software is written in Python. I had written this backend a few months ago, it has worked fine for me, so I decided to release it. Your feedback is welcome.
The following software is required so that this backend functions correctly:
- Python (http://www.python.org)
- CUPS server (http://www.cups.org/)
- Ghostscript (http://www.cs.wisc.edu/~ghost/)
- a postscript printer’s PPD file. (see Installation section)
- Email server, on which usernames from the LAN workstations either match the users on the email server or proper mappings (aliases) have been set.
Put the “
pdf2email” file in
/usr/lib/cups/backend/ and set the executable bit:
chmod +x /usr/lib/cups/backend/pdf2email
Open the script in a text editor and set a couple of settings:
1. Set the email server’s hostname:
SMTP_Server = "mail.example.org"
2. Set the email address of the sender as it will appear in the email:
print_admin = "email@example.com"
3. (Optional) Set the path to a text file that contains PDFmarks. If you don’t know what PDFmarks are, you should leave this variable empty. (see some more info in the PDFmarks section):
pdfmarks_file = ""
Configure a CUPS Printer
This section describes in brief all the required actions in order to add a printer that uses this backend to CUPS.
- Decide the printer’s name, eg “TestPDFprinter”.
- Decide the directory, where the PDF files are saved temporarily. This directory must be writable by the users. Usually,
/tmpis perfect for this. Note, that no PDF files are left in this directory. This piece of information is used in the Device URI of your CUPS printer. For example, provided that the
/tmpdirectory will be used, the Device URI would be:
- Get a postscript printer’s PPD file. You can find such files at:
WARNING: It is your exclusive responsibility to examine the printer driver’s license prior to using the PPD file. NO PPD FILES ARE SHIPPED WITH THE pdf2email BACKEND.
Finally, add a new printer that uses this backend, either by using lpadmin from the command line or by using the web-based administration interface of CUPS or by using any other CUPS Server management software.
Using lpadmin from the shell
As root issue the following command:
lpadmin -p TestPDFprinter -E -v pdf2email:/tmp -P /path/to/myprinter.ppd
Using CUPS web-based interface or other software
Use the provided “Add Printer” facility. Some notes that might be useful:
- In the device dropdown box, select the following:
Direct PDF Printing/Delivery to user email
- In the device URI box use the writable directory, eg:
- If asked about the type of the print queue, use “
Make this printer available to the LAN through the IPP, SAMBA or any other protocol and add it to your printer list in your client machines. Whatever you send to that printer will be converted to a PDF document and will be emailed to your user’s email address.
If any error occurs during the PDF creation process, there will be a failure notice in your inbox and a message in syslog (
In case you receive no email after requesting a print, check syslog for any error messages. If there aren’t any, the check CUPS error log.
Finally, note that if you use a security layer like SELinux, then you might need to further adjust it so it lets 3rd party CUPS backends to function. This is beyond the scope of this document.
If you do not know what pdfmarks are, please do a web search about them. This backend can include PDFmarks in the final PDF document. Do not expect anything spectacular, as this script cannot process the document for bookmarks, links etc. What it can do is to add pre-defined pdfmarks to all PDF documents.
For example, if, for example, you want to fill some of the document properties, save the following in a file:
[/Title () /Author () /Subject (blah blah) /Keywords (keyword1, keyword2, blah) /DOCINFO pdfmark
By default the author’s property is filled with the username that requested the print.
Finally, add the path to the pdfmarks file in the configuration section of the backend, as described in the configuration section:
pdfmarks_file = "/path/to/pdfmarks.file"
This feature has not been tested thoroughly.
This project is released under the terms of the GNU General Public License version 2 or later.
All versions of the software, including the latest stable release, are available from the development web site’s download area.
This software is released as free software without any warranties or official support. You can still get first class support from the community of users.
Bugs and Feature Requests
pdf2email CUPS Backend by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2006 - Some Rights Reserved