How to print to a receipt printer
I want to write my own POS for the restaurant where I work. How do I print tickets to the receipt printer. There are two printers: one is Impact and the other is Thermal. Does rebol have a built in printing function, or do I need to use call to use a windows function ?
posted by: Andrew 1-Mar-2017/16:51-8:00
If your receipt printer works with a regular OS printer driver, then you print to it like any other printer. You'll just need to adjust the layout of your printout so that it fits on the page. Here are some printing options: http://business-programming.com/business_programming.html#section-16.27 I used HTML to print receipts in the Merchants' Village software, and the PDF dialect to print docs that needed to be positioned exactly on a page (the bar code labels and checks were printed to PDF): http://freeconsignmentsoftware.com
posted by: Nick 1-Mar-2017/20:21:37-8:00
BTW, if you don't want to rely on the default installed browser or PDF viewer, you can use: http://offbyone.com https://sourceforge.net/projects/dplus-browser/ http://qtweb.net/ https://www.sumatrapdfreader.org etc... In the Merchants' Village software, there's a setting in the user interface, and appropriate logic to handle switching between default viewers and some of those stand alone options.
posted by: Nick 2-Mar-2017/5:02:27-8:00
Thank for the information ! However, I don't know if that way of printing will be good for my setting. I work in a fast food restaurant, so I need the ticket to print automatically after the order is paid. I also need the cash register to open up at certain times. I know there is something called cash register codes and printer codes, but I don't know how to find out what the codes are. In the printer properties under the ports tab is says USB001 for the printer. The cash register is connected to the printer.
posted by: Andrew 2-Mar-2017/14:22:50-8:00
Is there a way to send printer and cash register codes with rebol ?
posted by: Andew 2-Mar-2017/16:48:24-8:00
You can make HTML docs print automatically with: window.onload = function() { window.print(); } You'll see that, or something similar in the Merchants' Village code. You'll need to check the documentation published by the manufacturer of the draw to learn how to open the drawer.
posted by: Nick 2-Mar-2017/21:29:26-8:00
Thank you very much, Nick !
posted by: Andrew 3-Mar-2017/14:12:39-8:00
I contacted the manufacturer of the receipt printer used at my restaurant and he gave me some files. The files are libraries and sdk and things like that. There are also some programs written in Delphi, visual basic, java, and visual c which are used to test the printer. After you run the program, you select the port name and baud rate, click open, then you can click a button to open the register and other buttons to print test receipts. Would it be possible to use Rebol like those programs to open a port to usb and print receipts and open the register, or would I have to use one of the other languages like Delphi or Visual Basic or something ? I've been trying to research using rebol to open port to usb, but I haven't found or understood much. The most I've found is that rebol 3 has schemes or something. It doesn't seem too complicated to me, (but then again I'm so ignorant, so maybe it is complicated): just open a port, print the receipt (which is formatted to a certain size in the rebol program), send the code to cut the paper, send the code to open the register. Thanks
posted by: Andrew 21-Mar-2017/16:59:55-7:00
The current POS software I use has a "No Sale" button which just opens the register. You can also recall orders and print a copy of the receipt. It's instantaneous, too.
posted by: Andrew 21-Mar-2017/17:16:04-7:00
If they sent you some Dlls with VB6 examples, those are usually easy to convert to Rebol. You just need to get used to the syntax used to call functions in VB (there will be argument values of defined types, and probably a return value, which map to Rebol types): http://business-programming.com/business_programming.html#section-16.16 http://rebol.com/docs/library.html I converted all the functions in the library used in this example, directly from the VB6 code that shipped with it: http://www.rebol.org/view-script.r?script=mp3-player-libwmp.r&sid=b73qd
posted by: Nick 21-Mar-2017/21:43:08-7:00
Also, if they gave you a compiled program (maybe with command line argument options), to do things like open the register drawer, you could call that directly from Rebol too.
posted by: Nick 21-Mar-2017/21:45:20-7:00
Turns out I was overthinking what I need to do. You can just call the print command in windows. R E B O L [] ;drawer kick code is 27, 112, 0, 25, 250 ;printer cut code is 27, 109 drawerKick: rejoin [to-char 27 to-char 112 to-char 0 to-char 25 to-char 250] printerCut: rejoin [to-char 27 to-char 109] call rejoin ["print /d:USB data.txt" printerCut drawerKick] quit This doesn't work, though. All it does is create a file in the same directory called USB. If you change the call argument to just "print /d:USB data.txt" then the USB file is just a copy of data.txt. Here is the website where I got the information about the print command : http://www.computerhope.com/printhlp.htm I'm sure I'm missing something obvious; I'm rather ignorant =(
posted by: Andrew 23-Mar-2017/18:17:45-7:00
I really appreciate all of your help, Nick.
posted by: Andrew 23-Mar-2017/19:35:17-7:00
I got it to work !! =) R E B O L [Title: "Andrew's WIP Receipt Printer"] ;POS-X EVO RP1 is the model. The codes below will be different for other printers. ;drawer kick code is 27, 112, 0, 25, 250 ;printer cut code is 27, 109 write %printercut "" write %drawerkick "" write %data "" drawerKick: rejoin [to-char 27 to-char 112 to-char 0 to-char 25 to-char 250] printerCut: rejoin [to-char 27 to-char 109] marginBottom: rejoin [newline newline newline newline newline newline newline] ;The cutter on the printer is three lines below the top of the paper. It's necessary to insert six lines at the end of the ticket to make sure the the last three lines of the ticket aren't cut off. The seventh newline acts as the end of the ticket. write/append %printercut printerCut write/append %drawerkick drawerKick write/append %data rejoin [currentTicket marginBottom] doData: does [call "print /D:^"\\POS\POS-X Thermal Printer^" C:\Users\User\rebol\data"] doKick: does [call "print /D:^"\\POS\POS-X Thermal Printer^" C:\Users\User\rebol\drawerkick"] doCut: does [call "print /D:^"\\POS\POS-X Thermal Printer^" C:\Users\User\rebol\printercut"] ;"POS" is the Computer Name which is found by printing a test page from within the printer properties. "POS-X Thermal Printer" is the shared name found by sharing the printer and setting the shared name. ;Windows 7 is stupid and requires a file as the argument to print... or I'm stupid for not knowing of a different way lol doData wait 1 doKick wait 1 doCut wait 1 ;doKick and doCut don't seem to work unless the wait 1's are there. I've tried call/wait but that doesn't work either. quit
posted by: Andrew 24-Mar-2017/4:25:48-7:00
Great! That's a solution I never tried.
posted by: Nick 24-Mar-2017/12:06:14-7:00
|