Formatting text for printing to laser printers as well as line printers
1
vote
0
answers
259
views
I have a large custom built application for a client that runs on Java on a Linux system.
It produces a number of outputs (bills, etc) that are automatically printed on multiple printers. The way it is designed that there is a table defined for each user specifying the printer assigned to him. All users sit at fixed seats in multiple offices so this table doesn't change (much).
Previously, they had a few large line printers for the larger offices and Epson dot matrix printers for the smaller ones.
The application would generate each bill as a txt file and place it in a filesystem directory. I have a bash script that runs in a loop that looks for new files in each directory and sends it to print using the lp command, then deletes the txt file. The way it figures out which printer to send to is simple; the name of the printer is the same as the name of the directory.
After a long period of use, the line and dot matrix printers are falling apart and being replaced with laser printers. I updated my script that all laser printer names and corresponding directory names end with "-PS" and the lp command pipes it thru enscript to convert to PostScript.
Now, I am thinking of adding some formatting to the bills. Nothing fancy, just bold headings and perhaps some font formatting.
Reading up on enscript, I see that I can add escape codes as in Stack Exchange sample given here. That would fulfil the needs here.
However, if I add the escape codes to the txt file, while it would work for laser printers, it won't if that user has been assigned to a line or dot matrix printer. The script uses plain lp for them without piping thru enscript.
Any ideas would be welcome.
Asked by Hussain Akbar
(145 rep)
Jan 14, 2022, 01:55 PM