bastecklein's Wall

bastecklein

Developer
Member Since: 2017-09-02 00:09:04
Last Active: 2019-08-22 22:50:50
Post Count: 1802 (View Posts)
Brandon Stecklein (bastecklein) is the creator, owner, and principal developer of Ape Apps. He started the business back in 2010 and operates it out of Spring Hill, Kansas.
2019-07-25 23:51:34

Inkjet vs. Dot Matrix Printers

Ok, so I know that most people haven't even thought about a Dot Matrix printer since the late 1980's. Personally though, I have always been a fan of Dot Matrix printers, primarily for their superior durability, longevity, and low cost to operate. Anybody who owns a printer, whether it's an Inkjet or a Laser, is well aware of the outrageous cost for ink and toner, sometimes being even more expensive than the actual printer itself. This is why at home, whenever I am printing something non-critical, I tend to use my old Dot Matrix printer, an Epson LX-800 from 1987.
2018-12-27 22:51:09

Silent Printing on Electron

I have an old dot matrix printer (Epson LX-800) set up on an LPT port on a Windows 10 machine. I can print fine from Windows, but it uses graphics mode, takes forever, and the quality is not that great. I've always wanted to be able to print to this printer using the built in fonts (both draft and NLQ) but nothing I could find on Windows really supports it in an elegant way. So the other day I was updating my Ape Apps Launcher application, and decided that I would implement my own solution for printing to this printer, so that I could at least use it the way I want to in my own applications.

After searching the net for a good way to print silently with raw text and command codes to an old dot matrix printer, I decided to just roll a simple solution by saving all of the commands for the printer in a plain text file, and then printing it silently using the built in Windows 'print' command. The solution ends up working pretty good, and the code is dead simple:
var fs = require('fs');
var printString = "whatever text you need to print with optional ascii commands";
var printer = "lpt1";

var tmpFileName ="c:\tmp.txt";
fs.writeFileSync(tmpFileName,printString,"utf8");

var child = require('child_process').exec;
child('print /d:' + printer + ' "' + tmpFileName + '"');
The 'printer' variable can be either lpt1/lpt2 or a network printer share. See the reference for the print command here:

docs.microsoft.com/en-us/windows-server/administration/windows-commands/print

I haven't tried it, but I'm sure something similar can be hashed out for Mac/Linux using the lpr command.

Hopefully this helps somebody. I also posted this information on a Stack Overflow post here. I literally spent a day trying to get a more 'native' Electron/nodejs way for this to work, but it turns out sticking to the basics was the easiest way to accomplish it. And for those of you using the Ape Apps Launcher on Windows, you can benefit from the fruits of my work by enabling RAW/Text printing in the settings:


That is, if there is anybody out there besides me who still rocks an old dot matrix printer from the late 80's. But it's built into the Launcher now regardless, and comes pre-loaded with just about the entire ESC/P command set, so it should work on most dot matrix and probably receipt printers, from the 80's to today. I might use this new code to release an invoicing app for shops who still use these printers. We'll see!

Syndication