WLH
Posts: 1
Joined: Thu Jul 18, 2019 5:09 pm

RPi as virtual PDF printer hooked up throughout USB ?

Thu Jul 18, 2019 6:10 pm

Dear all,

I’ve been looking in several places to find an answer, but as I am not finding it, I fear a simple solution won’t be possible ....

I am thinking about setting up the RPi as a Print to PDF system.
I have several computers (interrogation programmers for cardiac devices) which print their interrogation data on built-in thermal printers, producing a massive amount of paper.
All of these computers are able to connect to an external USB printer. The only variable I can change is the printer driver.
An alternative possibility is to have these devices produce a pdf which they can save on a USB stick.

Is there a possibility to hook the RPi up to these computers through USB (one at a time off course) and have it capture the data sent to print to a PDF file.
Alternatively could it be possible to let the RPi function as a large USB stick and let the devices save their pdf file on the Pi. (I cannot change the location where the devices save their files (always root folder).

As the RPi helped me a lot with another (more simple) project (digital signage in waiting room) I was hoping to find a solution for this project.

Thanks for your thoughts.

User avatar
rpdom
Posts: 16983
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: RPi as virtual PDF printer hooked up throughout USB ?

Fri Jul 19, 2019 9:45 am

The Pi can print to PDF using the cups-dpf package, but the only ones that can be used as a USB device are the Zero range, the A models and possibly the Pi 4. Even so, I don't think any of them can emulate a printer via USB.

Over a network it should be easy.

Making a Pi Zero appear to be a USB storage device is possible. You'd need to define an area or file that is used for storage and wouldn't be able to access it while plugged in to USB, but with some reconfiguration it would be possible when removed from USB and rebooted.
Unreadable squiggle

Zanstel
Posts: 31
Joined: Thu Jul 18, 2019 9:05 am

Re: RPi as virtual PDF printer hooked up throughout USB ?

Fri Jul 19, 2019 10:12 am

I'm not sure what are you asking for, but the answer is YES.

Just a joke.

Well... If you want a printer to use by some devices, probably the easiest solution is to put a printer network services.
One could be a Windows printer, using Samba.

If you want to connect directly a RPi to a PC and see the RPi like a printer, I think it could be possible in the Raspberry Pi Zero (or Zero W), because it has USB OTG (On the Go). That's mean that the USB could be used to serve services, so the Raspberry could be shown like a massive storage, a ethernet, a serial, a keyboard or mouse, or a printer.

I don't try this ever. (In fact, I have some RPi but I don't have any Zero model), but technically, though the g_printer driver it should be possible to make a RPi Zero show as a printer.

The correct driver should be a standard one like a PostScript driver, so you can convert into a PDF easily.

hippy
Posts: 7378
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: RPi as virtual PDF printer hooked up throughout USB ?

Sat Jul 20, 2019 11:00 am

rpdom wrote:
Fri Jul 19, 2019 9:45 am
Even so, I don't think any of them can emulate a printer via USB.
It looks like it should be possible as there is a printer gadget ...

https://www.kernel.org/doc/Documentatio ... rinter.txt

In theory it should be possible to create gadgets which can do anything. In practice most users are limited to what others have already created and any limitations those implementations have.

User avatar
rpdom
Posts: 16983
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: RPi as virtual PDF printer hooked up throughout USB ?

Sat Jul 20, 2019 7:21 pm

hippy wrote:
Sat Jul 20, 2019 11:00 am
rpdom wrote:
Fri Jul 19, 2019 9:45 am
Even so, I don't think any of them can emulate a printer via USB.
It looks like it should be possible as there is a printer gadget ...

https://www.kernel.org/doc/Documentatio ... rinter.txt

In theory it should be possible to create gadgets which can do anything. In practice most users are limited to what others have already created and any limitations those implementations have.
Interesting.
Unreadable squiggle

RWAP
Posts: 22
Joined: Tue Aug 09, 2016 8:49 am

Re: RPi as virtual PDF printer hooked up throughout USB ?

Tue Jun 30, 2020 7:02 pm

I missed this post at the time unfortunately.

Did you ever get anywhere with this?

There are several issues to be addressed:

a) Can you change the printer driver on the machines? If not, what USB printers do they recognise?

b) To connect and get the Raspberry Pi (or similar) recognised by the machine you are most likely going to have to use a USB-OTG port to fool the machine into believing that what is connected is not an unknown device, but one of the supported printers.

c) With the knowledge of the type of printer supported, then you can use existing software solutions to convert the data to PDF.


The main issue is the USB-OTG port - the Raspberry Pi 4 has a programmable USB-OTG port, but I understand that this is also used to connect the PSU at present, so you need another means of powering the Pi. Earlier Raspberry Pis do not provide the ability to program the USB-OTG port.

I have done this previously on a Banana Pi and Odroid - basically intercepting data being sent to a connected USB printer (the Pi sits inline between the host machine and the printer). You will need a suitable printer at least initially to get the correct parameters to be programmed on the USB-OTG port.

There are three main types of printer - HP compatible, Epson ESC/P2 printers and Epson ESC/POS receipt printers.

HP Compatible output can be printed to PDF using GhostPCL.

Epson ESC/P2 needs specialist software such as our own software written for the Retro-Printer module (www.retroprinter.com)

Epson ESC/POS currently lacks any Linux based conversion software - although one could be written. There is some software which runs under Windows which can convert ESC/POS to PDF, but it is fairly expensive.

User avatar
scruss
Posts: 3142
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: RPi as virtual PDF printer hooked up throughout USB ?

Tue Jun 30, 2020 8:51 pm

The Raspberry Pi Zero and all of the Raspberry Pi A models can do USB OTG without power issues. Getting one to spoof a USB ESC/POS printer, though, won't be easy.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Networking and servers”