How to detect virtual & real-physical printers from Javascript

Overview

Sometimes, there are business polocies where certain documents should only be printed on physcal printers and web developers are given the task of just doing it. Determining whether a given client printer is a virtual or a real/physical device is not always straightforward but thanks to tools like JSPrintManager solution, you'd be able to get the needed printer information to infer it.

In this walkthrough, you'll learn how to use the printer info returned by JSPrintManager to trying determining whether a client printer is a virtual or a real/physical device. This solution works with any popular browser like Chrome, Firefox, IE/Edge & Safari on Windows, Linux, Mac & Raspberry Pi

NOTE: The source code for guessing whether a printer is virtual or a real/physical device works for any type of printer connectivity on Windows only. For Linux, Mac & Raspberry Pi/Raspbian, only USB printers are considered.

The sample code will output a page like the following:

A sample list of installed printers and whether they are virtual or real-physical devices

Follow up these steps

Be sure you install in your dev machine JSPrintManager (JSPM) (Available for Windows, Linux, Raspberry Pi & Mac)This small app must be installed on each client that will print from your website!

By using your favorite Web Development IDE or Text Editor, create a new HTML file like index.html
Copy/paste the following snipped codes: