Installing Virtual PDF Printer on Linux / Linux / CentOS / Installing Virtual PDF Printer on Linux

On Linux, you can use the cups-pdf package to implement a virtual PDF printer. What is a PDF printer? This is a virtual device that is added to the system as a regular printer and when a document is sent for printing, it generates a PDF file from it.

Verify that the Common UNIX Printing System (CUPS) printing subsystem is installed on your Linux host. Check if the computer is listening on port TCP/631 and that the cups service is up and running:

$ sudo netstat -tupnl
$ sudo systemctl status cups

check cups service is installed on linux

You can now install the cups-pdf package:

  • On Ubuntu/Debian:
    $ sudo apt install cups-pdf
  • On RHEL/Fedora/CentOS:
    # yum install cups-pdf

install cups-pdf virtual printer on linux

Restart the cups print service:

$ sudo service cups restart

List installed printers and show which printer is assigned as the default device:

$ sudo lpstat -p -d

CUPS-PDF (Virtual PDF Printer)
system default destination: PDF
device for PDF: cups-pdf:/

lpstat - list default pdf printer on linux

If the printer is disabled, you can enable it:

$ cupsenable CUPS-PDF

You can manually create a new virtual PDF printer in CUPS with the command:

$ sudo lpadmin -p cups-pdf -v cups-pdf:/ -E -P /usr/share/ppd/cups-pdf/CUPS-PDF_opt.ppd

If a virtual printer appears in the list, you can send any documents to it and save the result as a PDF file. By default, files in the name-job_N.pdf format are saved to the user’s ~/PDF directory.

You can change the directory path for the PDF files in the /etc/cups/cups-pdf.conf configuration file (Out ${HOME}/PDF).

linux: print to pdf files

You can manage the virtual PDF printer’s settings and print queue through the CUPS web interface.

In your browser, navigate to the http://yourcupshost:631/printers

Select the Generic CUPS-PDF Printer (w/ options)

Here you can change the print settings (page size, output resolution), share the printer, clear the print queue, etc.

manage virtual pdf printer settings via cups web inerface

Description:       PDF
Driver:  Generic CUPS-PDF Printer (w/ options) (color)
Connection:       cups-pdf:/
Defaults:             job-sheets=none, none media=iso_a4_210x297mm sides=one-sided

You can print to PDF from any application or directly from the Linux console. For example, to save the console output to a PDF file, simply pipe it to lpr (the default printer is used to print).

$ cat /etc/cups/cups-pdf.conf | lpr

Or, you can send the text file to be printed to PDF in the following way:

$ lp -d PDF testfile.txt

print console output pdf file on linux


3 thoughts on “Installing Virtual PDF Printer on Linux”
  1. I’d like to do this on a server that listens on 9100 for raw print jobs and have them go to that printer. Any idea on how to accomplish this? I’ve been googling for hours.

  2. There are a few existing queues on the server. I wanted to know how to those queues were created? using what command and the configuration of the printers.


Leave a Reply

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