I want to print text to a matrix printer from a FastReport dot-matrix report.
I've installed an Epson matrix printer in Windows and configured it to print to FILE: (because I don't have access to the actual printer yet).
If I use TfrxReport.Print
the result looks like it's not text, but graphics - lots of escape codes (fine) but no readable text:
1B 40 0D 1B 74 01 1B 36 1B 52 00 1B 50 1B 78 01 ; .@..t..6.R..P.x.
1B 32 1B 43 46 0D 0D 1B 4A 10 1B 5C 91 03 1B 4C ; .2.CF...J..\'..L
2C 00 3C 42 81 81 81 81 42 3C 00 00 00 00 04 0C ; ,.<BB<......
...
40 40 63 00 00 00 00 00 01 01 00 00 00 00 00 00 ; @@c.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 0C ; ................
02 01 01 02 0C 10 00 00 00 00 03 10 04 04 04 05 ; ................
15 1F 00 00 00 00 00 1F 10 00 00 00 10 0F 00 00 ; ................
...
I've read about TfrxDotMatrixExport, but then I'd have to export to a file, somehow send the file to the printer, and remove the file. I'd rather not do that.
Is there a way to print a text-based report as text, directly to a printer?
I'm not sure what you're expecting here, but you simply need to feed a dot-matrix printer ASCII text files. If you want to print stuff other than ASCII characters, then you can send out ESCape codes and followed by 7- or 8-bit data to print the data as pixels. This text is full of ESCape codes at the beginning, presumably to set it up in bit-map mode. Each printer can be slightly different, but most printers standardized on Epson's escape sequences. Since you're using an Epson printer, I'd suspect that when you plug it in, this data will print what you're expecting to see, albeit rather slowly. (One of those ESC codes should tell the printer to print in bi-directional mode to speed it up.)
I don't recall if the pixel data is sent in columns or rows (probably columns if the head is 7 or 8 pins tall), but what you've got there looks like what I'd expect to see. All of those 1b characters are ESCape characters. Their purpose was to tell the printer to start accepting some inline options that changed the way the printer interprets the data -- as in how the pixels of the print head are to be rendered.
Dig up an old Epson printer manual to decode what the ESC sequences are here. Or ask Google.
Most printers today will still accept these, even laser and ink-jet printers; you don't need an Epson. If you have a printer, go to the vendor's site and look for info that talks about the ESC code sequences that it supports. HPGL mostly replaced Epson for page-level rendering, but virtually every printer in the world should accept normal ASCII data and most would also support Epson ESCape codes, if not HPGL as well.