Live data from Hacker News

Bye CUPS: Printing with Netcat

retrohacker.substack.com

11–20 of 183 posts

Re: Bye CUPS: Printing with Netcat

#12

How would you get an application, such as Firefox or Chrome, to know to use netcat to print?

Today I: CTRL+P -> Save to PDF.

If I want to print multiple pages per sheet: Open PDF in Firefox, CTRL+P -> Save to PDF and configure the document. You can also pipe through `gs` to do this.

For _huge_ documents (100s of pages), I'll pipe through `gs` first to do the pdf->ps conversion on my laptops CPU. The printer can do it, it just takes a lot longer.

Re: Bye CUPS: Printing with Netcat

#14
I just tried this and while it worked, it was very slow. It takes a minute to start printing a page in a PDF, meanwhile nc is still hanging and sending the data, seemingly very slowly. The printer is constantly showing "Receiving Data" on its screen. The PDF is only 450KB.

Edit: It took about 5 mins to print a 3-page document, with long pauses between each page.

Re: Bye CUPS: Printing with Netcat

#15
YMMV as the printer needs to support PCL/PDL and not all HP network servers have it built-in. HP chose to save some money by making dumb network cards that forced the PCL/PDL rendering on the Windows computer which made using Linux difficult.

http://danieru.com/2013/06/06/what-is-port-9100-how-to-print...

While you're at it you may as well try out the printer exploit kit https://github.com/RUB-NDS/PRET

Re: Bye CUPS: Printing with Netcat

#16
I once did something similar to that on my previous job. A colleague came by asking who printed several pages of garbage. Me: "Sorry, I just inferred every reputable printer supported postscript". The problem: the job was an outsource for a pinter vendor. They obviously did not like my comment.

Re: Bye CUPS: Printing with Netcat

#17
post #6

How would you get an application, such as Firefox or Chrome, to know to use netcat to print?

Choose Jetdirect/Appsocket in the printer add menu and it will do the same thing. There is nothing magic about netcat. You are just dumping Postscript/PDF data on a TCP port the printer is listening on.

Oh fascinating. If I use the system dialogue, I can choose the application to print to. There is an `lpr` option, and I can specify the application it invokes in a "Command Line" field.

I can put `nc [printer_ip] 9100` there and it will just print. I just printed your comment this way.

That's cool! Thank you for teaching me something!

Re: Bye CUPS: Printing with Netcat

#18

This is how this Hackernews printed several pages worth of the plaintext representation of a PDF on an office printer a few years ago before figuring out how to cancel the job.

So how did you cancel it? I assume killing the nc process wasn't enough because it had buffered the whole file, so you had to do it at the printer?

Re: Bye CUPS: Printing with Netcat

#19

I just tried this and while it worked, it was very slow. It takes a minute to start printing a page in a PDF, meanwhile nc is still hanging and sending the data, seemingly very slowly. The printer is constantly showing "Receiving Data" on its screen. The PDF is only 450KB. Edit: It took about 5 mins to print a 3-page document, with long pauses between each page.

I suspect it's the printer doing the pdf->ps conversion. I have a beefy printer, so only run into this for large documents. But I'll cat through `gs` then to `nc` to do the pdf->ps conversion locally, and it is much faster.

Re: Bye CUPS: Printing with Netcat

#20

I just tried this and while it worked, it was very slow. It takes a minute to start printing a page in a PDF, meanwhile nc is still hanging and sending the data, seemingly very slowly. The printer is constantly showing "Receiving Data" on its screen. The PDF is only 450KB. Edit: It took about 5 mins to print a 3-page document, with long pauses between each page.

I suspect it's the printer doing the pdf->ps conversion. I have a beefy printer, so only run into this for large documents. But I'll cat through `gs` then to `nc` to do the pdf->ps conversion locally, and it is much faster.

That makes sense. That's why you want to do print spooling on client devices, which run on extremely fast CPUs in comparison. I guess that is why we don't send documents directly to printers.
Post reply on HN