[Tutor] printing

alan.gauld@bt.com alan.gauld@bt.com
Mon, 11 Mar 2002 18:54:43 -0000


------_=_NextPart_001_01C1C92E.34E5F990
Content-type: text/plain; charset="ISO-8859-1"

 >  How do you send data to the printer? 
 
Theeasy way, for text is:
 
os.system('lpr foo.txt') # *nix
 
OR 
 
os.system('Print foo.txt') # DOS 
 
Or just assign stdout to prn:
 
Or open PRN: as a file
 
For fancier work you are probabluy best to generate 
an HTML file or PDF and print that using the native 
tools as above.
 
If you must do it in Windows native printing then its HARD!
You need to create a device context on the printer and 
draw the output using GDI commands. The theory is that 
the same GDI calls generate the display and the print
(hence WYSIWYG) but in pracxtice its not that simple!
 
On *nix its usually via runoff macros of some type.
 
Alan g

------_=_NextPart_001_01C1C92E.34E5F990
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial><FONT size=2><SPAN class=810085818-11032002><FONT 
face="Courier New" color=#0000ff>&nbsp;&gt; &nbsp;</FONT></SPAN>How do you send 
data to the printer?<SPAN class=810085818-11032002><FONT face="Courier New" 
color=#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=810085818-11032002><FONT 
face="Courier New" color=#0000ff>Theeasy way, for text 
is:</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=810085818-11032002><FONT 
face="Courier New" color=#0000ff>os.system('lpr foo.txt')&nbsp;# 
*nix</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=810085818-11032002><FONT 
face="Courier New" color=#0000ff>OR&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=810085818-11032002><FONT 
face="Courier New" color=#0000ff>os.system('Print foo.txt') # 
DOS</FONT>&nbsp;</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>Or just assign stdout to 
prn:</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>Or open PRN: as a file</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>For fancier work you are probabluy best to generate 
</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>an HTML file or PDF and print that using the native 
</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>tools as above.</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>If you must do it in Windows native printing then its 
HARD!</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>You need to create a device context on the printer and 
</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>draw the output using GDI commands. The theory is that 
</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>the same GDI calls generate the display and the 
print</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>(hence WYSIWYG) but in pracxtice its not that 
simple!</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT face="Courier New" color=#0000ff size=2><SPAN 
class=810085818-11032002>On *nix its usually via runoff macros of some 
type.</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=810085818-11032002><FONT face=Arial size=2>Alan 
g</FONT></SPAN></DIV></BODY></HTML>

------_=_NextPart_001_01C1C92E.34E5F990--