Forum OpenACS Q&A: Solution: Printing with printer control fonts from HTML

Collapse
Posted by Michael Hinds on
Having got as far as having the correct sequence of characters to open the drawer, it was just a case of how to send a file directly from the web server to the printer (without IE corrupting it). We have a captive audience, so we have the luxury of being able to fiddle with OS settings. I personally have the added advantage of sitting across the room from Brian so I know this works :) Assuming a Windows 2000 environment with the printer set to be the default, here's what to do:
    1. Put the binary file containing the control chars under the page root somewhere. Give it a .till extension.
    2. On the client PC, create the file c:\snozone\print.bat with the contents:
      copy %1 lpt1
    3. 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
    4. 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.
    5. It's easy enough to call this from JavaScript in a new window or a hidden frame.