User Tools

Site Tools


sending_20raw_20data_20to_20a_20printer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sending_20raw_20data_20to_20a_20printer [2018/03/31 13:19] – external edit 127.0.0.1sending_20raw_20data_20to_20a_20printer [2024/01/05 00:21] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Sending raw data to a printer===== =====Sending raw data to a printer=====
  
-//by Richard Russell, December 2006//\\ \\  Normally BBC BASIC for Windows outputs to a printer using the Windows printer drivers. This is useful in presenting a uniform interface; you don't have to concern yourself with the particular manufacturer and model of printer. To change the font you can use ***PRINTERFONT** and to output graphics you can use ***HARDCOPY** (or the [[/Writing%20graphics%20to%20the%20printer|Windows API]]) secure in the knowledge that it will keep working even if you change your printer to a different type.\\ \\  However there may very rarely be a requirement to bypass the printer driver and output raw data directly to the printer. For example it may be a specialised printer with a feature not normally accessible via the drivers. In that case you can use the procedure listed below to achieve it:\\ \\ +//by Richard Russell, December 2006//\\ \\  Normally BBC BASIC for Windows outputs to a printer using the Windows printer drivers. This is useful in presenting a uniform interface; you don't have to concern yourself with the particular manufacturer and model of printer. To change the font you can use ***PRINTERFONT** and to output graphics you can use ***HARDCOPY** (or the [[/Writing%20graphics%20to%20the%20printer|Windows API]]) secure in the knowledge that it will keep working even if you change your printer to a different type.\\ \\  However there may very rarely be a requirement to bypass the printer driver and output raw data directly to the printer. For example it may be a specialised printer with a feature not normally accessible via the drivers. In that case you can use the procedure listed below to achieve it: 
 + 
 +<code bb4w> 
         DEF PROCprintraw(S$)         DEF PROCprintraw(S$)
         LOCAL P%         LOCAL P%
Line 9: Line 11:
         SYS "Escape", @prthdc%, 19, 0, P%, 0         SYS "Escape", @prthdc%, 19, 0, P%, 0
         ENDPROC         ENDPROC
-This routine sends a character string directly to the current printer, bypassing the drivers.\\ \\  To use the routine you must first output at least one conventional character to the printer, for example a space, to initialise it. For example you might use the code below to send data to a printer which accepts Hewlett Packard PCL5 commands:\\ \\ +</code> 
 + 
 +This routine sends a character string directly to the current printer, bypassing the drivers.\\ \\  To use the routine you must first output at least one conventional character to the printer, for example a space, to initialise it. For example you might use the code below to send data to a printer which accepts Hewlett Packard PCL5 commands: 
 + 
 +<code bb4w>
         VDU 2,1,32,3         VDU 2,1,32,3
         PROCprintraw(CHR$27+"&l12E"+CHR$27+"(s1p24v0s0b410THello world!")         PROCprintraw(CHR$27+"&l12E"+CHR$27+"(s1p24v0s0b410THello world!")
         VDU 2,1,12,3         VDU 2,1,12,3
 +</code>
 +
 This code first sets a top margin then selects a 24-point Times font before printing the string **Hello world!** This code first sets a top margin then selects a 24-point Times font before printing the string **Hello world!**
sending_20raw_20data_20to_20a_20printer.1522502381.txt.gz · Last modified: 2024/01/05 00:16 (external edit)