Forum OpenACS Q&A: Printing with printer control fonts from HTML
Not really appropriate to OpenACS Q&A, but I'm hoping for some help in the spirit of the original Web/DB! Nobody else can seem to help me.
I've got an electronic till cash drawer attached to an Epson thermal (receipt) printer. The opening of the cash drawer is controlled by printing a certain letter in a certain Control font to the printer. This works fine as per the manual when I'm printing from Microsoft Word or Wordpad. My problem is trying to do this from HTML. I select my thermal printer (this should make the control font available), open and print a simple web page that looks like this:
<FONT FACE="control" size="10">A</font>
Instead of interpreting this as a control font command and passing it on to the cash drawer, the printer just prints out the letter A (which is one of my favourite letters, but not quite what I want to see coming out of my receipt printer!)
One of the guys here in the office said that the problem is that browsers print an image of whatever's on the page to the printer, rather than sending the actual page content. Is this true?
I had a brief and unhelpful chat with Epson's technical support? They had no idea how to print the control font from HTML, said they'd get back to me and never did.
Can anyone suggest a way I might achieve this? Any useful 3rd party products that I could look at? I've got a pretty ugly workaround using Scriptx from meadroid.com which involved opening MS Word and printing from there. Yack!
Maybe it is JUST a Lovely "A". I assume that printer control codes are ESCaped or something. What does the "Control" font
thanks for the reply. I'm not sure I fully understand your question. Are you asking me what the printer "sees" when the letter A is sent to it using the control font? If so, I'm afraid I don't know the answer to that. Is there an easy way of seeing that? In terms of what I see, I have a Word document with the letter A, I have my printer defaulted to my Epson thermal printer and my chosen font is "control". So it looks like any other Word document. I only get the control font in my list of fonts when I select the thermal printer.
I tried saving the Word document as RTF and opening it in a text editor (Textpad) and printing from there, but that just prints the A, instead of opening the till drawer. I don't know how to preserve the font information in a text format.
Can you print any other characters in the Control font, like a cents sign, or something that should print a character on the paper? That is the first test to determine whether the font is being used by the web browser.
thanks for the reply. Yes, I've narrowed it down a little bit more since. It appears the browser (IE 5.5 on Windows 2000) can't seem to see that font. The following page displayed the letter A using fantasy font (it ignored the contol font):
<FONT FACE="control, fantasy" size="9.5">A</font>
I tried using a media=print style as follows but that too printed in the fantasy font when I printed the page out:
font-size : 9.5pt;
font-family : fantasy;
font-size : 9.5pt;
font-family : control;
I've also since verified that text is indeed printed as text, not as an image as I originally thought.
Any other suggestions?
seeing if you can put the literal codes sent
to the printer in the page?
My guess is this won't work either but it's worth a try...
Yes I've tried that. I just get a print-out of gibberish.
I think the key to the problem is persuading IE to use the control font. Any idea how I might do that?
Thanks for the feedback. Yes, I already considered that. There are 2 problems with that: firstly, the manual doesn't explain any of that kind of detail. It simply says to select the control font and print that. I've tried printing to file, saving as text, anything else I could think of, but I can't extract that kind of information. The second problem with that is HTML only permits 3 control characters: Horizontal tab, line feed and space, so even if I knew the characters, I've no guarantee HTML will be able to print them.
I've been scouring the web all week. I don't understand much about fonts (or Windows programming in general) but there seems to be almost no information out there about how browsers handles fonts, specifically printer fonts. Odd.
The changing of fonts when you print from Windows / IE will be effected by a combination of Windows, the printer driver for this printer, and IE. In the end, a few special ASCII characters will be shipped to the printer telling it to switch to "control font" and interpret the subsequent received characters as action directives instead of characters to print on the printer. Another control sequence will return to regular printing.
You really need to find this control character sequence. There must be a way to inspect the printer driver to see what it does to invoke fonts, but I am unaware of how to do so. So you need to rely on printing a very small Word file (that includes identifiable conventional text before and after the control font character) to a file and inspecting it with a hex editor is the way to determine the control character sequence used. (It sounds like you've done this already.) I can help you examine the file if you send it to me. Shame on Epson for not prividing the details!
When we figure out the sequence required, we can then play with making it happen in HTML.
There is more relevant stuff in the documentation that I haven't read in detail, but let's try this now. If it doesn't work, we can probe further.
yes I already tried one of the other non-Extended fonts (10cpi). Again the problem appears to be that IE can't see the printer fonts.
I think your other idea about which ASCII characters tell it to switch to the control font is worth chasing.
Thanks for the suggestions!
It might help for you to drive the printer / till directly without Windows in the picture (got an old DOS machine?) and learn what character sequences actually make the unit do what you want. Then step two is to make Windows / IE generate that sequence.
append header "<p STYLE=\"page-break-before: always\">
im sure there are many other printer centric stylesheet settings ?
DOS machine? I wish!
Allen, thanks for your suggestion. I'll look into it.
Allen, I had a look at some of the CSS2 tags you mentioned. I couldn't see anything about fonts though. Thanks for the help anyway.
I've pared in a binary editor the print file Word created down to the minimum size that still opens the till drawer (when I copy it to LPT1 from a Windows command prompt). It's only got 5 characters! I've posted it up here: http://www.quest.ie/brian/test3.prn
Any ideas how to convert that to something the browser can use?
I got an interesting suggestion from another source. He said:
"you could try configuring the browser's monospace font (or one of the weird ones like cursive or fantasy) to be the control font, and then change the HTML to use the monospace font. Of course, if you need the monospace font for something else this won't help. I have a feeling though, that if it won't use the control font by name, it probably won't let you use it as a 'special' font. Perhaps the font is a raster font or something and the browser ignores raster fonts."
When I asked him how I might do this, he never replied! Does anyone know how to configure the browser (IE 5.5 and 6.0) like this?
The manual revealed more info on a closer reading. The special characters 81H etc. appear not to work if you choose a "xxx cpi" font (see Sheet 17). There are two native printer fonts (Printer Font Small and Large) (Sheet 11) that should let 83H through. So try putting into your html something like <span style='font-family:Printer Font Small'>ƒ</span> and see if that works.
You might also poke into the printer driver files to learn how they control the printer, which might give you some insights. I found the printer driver files on my Windows 2000 under \WINNT\system32\spool\drivers\w32x86\*. The *.gpd files are text files that control printer functions other than fonts - explore those. Your drivers are probably named Tm* (Sheet 22).
I've decided not to put any more time into this problem. The work-around will have to do. Many, many thanks for all your time and efforts. I hope I can re-pay the favour some time.
- Put the binary file containing the control chars under the page root somewhere. Give it a .till extension.
- On the client PC, create the file c:\snozone\print.bat with the contents:
copy %1 lpt1
- On the client PC, associate .TILL files with the batch file. To be pedantic:
- In Windows Explorer, click on Tools -> Folder Options...
- Click on the "File Types" tab
- Click "New"
- Type .TILL as the file extension then click "OK"
- This should appear in the list of registered file types and should be highlighted.
- Click "Advanced"
- At the top, change the name from FT00000n to TillDrawerOpener
- Untick "Confirm open after download"
- Click "New..."
- Enter Print as the action
- Enter c:\pathtofileyoucreated\print.bat "%1" as the application used to perform action
- Say the magic words "Open sesame" while requesting the file in IE. You should very briefly see the download dialogue and a command prompt flash on the screen, and the till drawer will open.
i indirectly got my "control" Font. as brian says
WE can get control font if we set our default printer to pos printer. i use tm-u220b.
brian and others.
epson use character out side from writeable ascii.
so we almost can't use any writed text to control the printer function such as cut partial or other function.
i use comport tool kit which can send hex character.
for example i can cut partial if i send 1B 69 (in hex)
try communication tool program to send hex character.
and there is other trick to use normally word pad to send character under writeable ascii. it's by using control font which translate our font to unwriteable ascii (control character in ascii table).
i also got epson advance driver. now i will translate what is control font send to printer.
i will use cable from com 1 to com 2. then from com 1 i send control font. i rread from com 2 by comport tool kit to get it's hex value. if you have other snipper program to sniff com port, you don;t have to use any cable. just sniff it.
comport tool kit will give ablility to sniff but with limited periode. i already expired.
PS: we can discus diectly to firstname.lastname@example.org
I need to use printer font for fast reciep printing,
but under .net i cannot assign the font becouse it is not ttf. I can see those fonts in word pad, but i gues that in .net only ttf can be assigned.
In vb6 and good old printer object everything works fine.
and cash door opens
good old vb6 :(
1. Identify the control code that will open the cash drawer, for me this worked by opening a DOS Command prompt and typing "echo ^[p0>lpt1" (my open code is ESC p 0 for an Epson TMU200D connected to LPT1.)
2. In VBScript, use the FileSystemObject to "write" this command to LPT1 as follows:
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objPrint = objFS.CreateTextFile("LPT1:", True)
objPrint.Write(Chr(27) & "p0")
3. From your HTML page, execute this script, either onLoad or via button push.
4. Experience joy as the drawer opens!
The info was pretty needful. Am looking out for printing image, through thermal printer.
Am using ATP-80K printer.
Text printing works very fine. This printer is connected to COM port and not LTP1.
"Text printing works very fine. This printer is connected to COM port"
i have the problem on printing the text to Epson thermal printer(slow printing) where im using php for my system..
Is there anyway to set the printer font at html?
kindly anyone please help
I've got an Epson TM5000II connected on LPT1. The DOS command "echo ^[p0>lpt1" does instantly pop open my cash draw. I can't get your FileSystemObject code to work however. I'm trying to get my cash draw to pop open when I complete a shop transaction on my POS software which is web based. I'm using IE 7. When I put the code into my page all I get is a 'File Not Found' error on the 'Set objPrint = objFS.CreateTextFile("LPT1:", True)' line.
Sorry to be a div but I don't know how to 'execute this script, either onLoad or via button push' part so I simply slotted the code into my page header, which is why I probably get this error. Perhaps you can explain a bit further how to execute this code using OnLoad. If the draw popped open when the page loads it would be ideal.