Dot Matrix Printing for Inward Deposit and Payment Receipts - hmislk/hmis GitHub Wiki

Dot-Matrix Printing for Inward Deposit & Payment Receipts

Coop and other sites print inward deposit and payment receipts on 5ร—5 continuous stationery using an Epson LQ-310 impact printer. The normal browser print path rasterises the page to a bitmap, which prints mushy and unreadable on an impact head. This page explains the two print options added to fix that and how to set up the client machine.

The three print buttons

On the deposit / payment print-preview screen (and their reprint screens):

Button What it does Use when
Print The existing paper format (POS / 5ร—5 / A4 as configured). Laser / inkjet / POS printers.
Print (Dot-Matrix) A clean monospace receipt, printed through the normal browser dialog. LQ-310 with the ESC/P driver set to a native font (see below). Try this first.
Print (Raw Text) Downloads a .prn file of the receipt as raw text. A small agent on the PC sends it straight to the printer, bypassing the driver. If Print (Dot-Matrix) is still not crisp enough. Matches how standalone billing apps print.

Track A โ€” Print (Dot-Matrix): printer & Chrome settings

  1. Install the printer with the Epson LQ-310 ESC/P2 driver (Windows "Add Printer" โ†’ Epson โ†’ LQ-310). Do not use a generic / text-only driver here.
  2. Printer Properties โ†’ Printing Preferences โ†’ Advanced:
    • Print Quality = Draft or LQ (Near Letter Quality) โ€” not "Photo" / "Best".
    • "Print Text as Graphics" = OFF (label varies: "Send TrueType as Bitmap = No", "Print Mode = Native", "Graphics = Draft").
    • Paper size = custom 5 in ร— 5 in (or your form's real length).
    • Paper source = Tractor / Continuous.
  3. In the Chrome print dialog for this printer:
    • Margins = None
    • Scale = 100 / Default
    • Headers and footers = OFF
    • Background graphics = OFF
    • Set it as the default destination and click Save.
  4. If the receipt prints over your pre-printed letterhead, set the ConfigOption Inward Dot Matrix Receipt Preprinted Stationery = true (per department) and tune Inward Dot Matrix Receipt Top Margin Lines (default 8) until the body clears the pre-printed logo.

Track B โ€” Print (Raw Text): client-machine setup

The .prn file must reach the LQ-310 as raw bytes. Pick one option.

Option 1 โ€” Manual (quick test, no automation)

  1. Share the printer (share name e.g. LQ310) or note its LPT port.
  2. After clicking Print (Raw Text), from a Command Prompt:
    copy /b "%USERPROFILE%\Downloads\inward-deposit-123.prn" \\localhost\LQ310
    
    (or ... \\.\LPT1). It prints immediately, crisp, with no driver rasterisation. Use this to confirm quality before setting up the agent.

Option 2 โ€” Watched-folder agent (recommended for daily use)

The agent sends raw bytes to the printer's local UNC share, so the printer must be shared on the cashier PC itself. No admin rights are needed anywhere in this procedure.

  1. Share the printer locally: Printer Properties โ†’ Sharing tab โ†’ tick "Share this printer". Any share name will do โ€” the agent looks it up from the printer name.
  2. Copy the contents of tools/client-print-agent/ (from the repo) to C:\hmis-print\.
  3. Copy print-agent-config.example.json to print-agent-config.json in that same folder and set:
    • WatchFolder โ€” where Chrome saves the .prn files, e.g. C:\hmis-print
    • PrinterPath โ€” the exact installed printer name from Settings > Printers & scanners (e.g. DEPOSIT), the one you just shared
    • FileGlob โ€” inward-*.prn
    • PollSeconds โ€” how often to check the folder, e.g. 2
  4. In Chrome โ†’ Settings โ†’ Downloads: set Location to C:\hmis-print\ and turn OFF "Ask where to save each file".
  5. Put a shortcut to start-agent-hidden.vbs in the current user's Startup folder, %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup, so the agent starts hidden at every logon. (This replaces the old Task Scheduler route, which many cashier PCs won't allow for a standard account.)
  6. Log off / on, or double-click the shortcut to start it immediately. Confirm agent.log โ€” written next to the script, not in the watch folder โ€” shows a watching ... -> <printer> (\\...\...) line.

Now Print (Raw Text) โ†’ file lands in C:\hmis-print\ โ†’ agent prints it โ†’ file is deleted. Fully hands-off.

How the agent handles failures

  • Each file is renamed to .processing before printing, so the same receipt can never be picked up and printed twice.
  • If the printer is unavailable, the job is retried a few times and then moved to a failed\ subfolder โ€” not retried forever on every poll.
  • If the agent is killed mid-job (reboot, logoff, crash), the leftover .processing file is moved to failed\ at the next startup. It is deliberately not reprinted, because the interrupted run may already have sent it to the spooler. Check whether it printed before re-dropping it into the watch folder.
  • Starting the agent twice over the same folder is blocked by a named mutex, so a manual start on top of the Startup one cannot double-print.

Troubleshooting

Symptom Fix
Control codes (โ†@, โ†x) printed literally on the page The transport is stripping / re-encoding 8-bit bytes. Set ConfigOption Inward Raw Text Receipt Emit ESC/P Codes = false for pure ASCII.
Nothing prints, no error Printer share name / LPT path wrong. Test with the Option 1 copy /b command first.
agent.log shows FATAL: no printer named '<name>' is installed PrinterPath in print-agent-config.json must match the printer's exact name in Settings > Printers & scanners.
agent.log shows FATAL: printer '<name>' is not shared The agent sends raw bytes via the printer's local UNC share. Printer Properties โ†’ Sharing โ†’ "Share this printer".
Agent starts and logs watching ... but nothing prints Check the failed\ subfolder of the watch folder โ€” undeliverable jobs are moved there rather than retried forever. agent.log names each one.
copy /b to a remote share fails with "Access is denied" The account lacks file-share permission on the print server's queue. Share the printer locally on the cashier PC instead and point PrinterPath at that local printer, so the agent uses \\<this-pc>\<sharename> and needs no permission on the remote server.
Prints half the receipt then ejects the whole form Form length in the driver โ‰  your stationery. Set the custom paper size to the real form length; the raw path emits one form-feed at the end.
Two copies of the receipt on screen The dot-matrix preview is meant to be hidden until you print. If it shows, the Inward Payment Bill Dot Matrix Paper config is on โ€” that is expected (it makes the monospace receipt the default preview).
Body still overlaps pre-printed header Increase Inward Dot Matrix Receipt Top Margin Lines (Dot-Matrix button) or Inward Raw Text Receipt Top Margin Lines (Raw Text button).

ConfigOption reference

Key Type Default Scope Effect
Inward Payment Bill Dot Matrix Paper bool false global/dept Makes the monospace receipt the default on-screen preview + plain Print target.
Inward Dot Matrix Receipt Preprinted Stationery bool false dept-first Suppress the app's text header; drop the body below pre-printed letterhead.
Inward Dot Matrix Receipt Top Margin Lines int 8 dept-first Blank leading lines when the above is true.
Print Barcode on Inward Dot Matrix Receipt bool false global/dept Include the (bitmap) barcode. Off for LQ.
Inward Raw Text Receipt Preprinted Stationery bool false dept-first Same as its Dot-Matrix twin, for the Raw Text file.
Inward Raw Text Receipt Top Margin Lines int 8 dept-first Blank leading lines in the Raw Text file.
Inward Raw Text Receipt Emit ESC/P Codes bool true global/dept Wrap the file in ESC/P init + form-feed. Turn off if the transport mangles control bytes.
โš ๏ธ **GitHub.com Fallback** โš ๏ธ