windoze printing
- Posted by wolfgang fritz <wolfritz at KING.IGS.NET> Oct 10, 1998
- 620 views
...any windoze folks out there who can TEST this code-chunk for me ? Uses the api_wrap stuff... My "dinky" printer does not allow any font settings in printer properties, so I'm not sure if I got the TextMetrics "thingie" right or not. Any simple Notepad text should serve as input. ** caution ** comment out the global function DeleteDC() at the end of print.ew, as it conflicts with the procedure DeleteDC() in gdi32.ew... ...any feedback much appreciated...Wolf ------------------------------------------------ include gdi32.ew include print.ew include msgbox.e procedure print_stuff(sequence a) -- a is filename atom myprinterhdc, i, charheight sequence myprintername, textinfo i=message_box("make sure printer is on !"," ",#2000) myprintername=DefaultPrinterName() -- uses the default printer myprinterhdc=GetPrinterDC(myprintername) textinfo=GetTextMetrics(myprinterhdc) charheight=textinfo[1] i=StartDoc(myprinterhdc, a ) i=StartPage(myprinterhdc) TextOut(myprinterhdc,360,30,"A Printing Example") Handle=open( a ,"r") j=charheight while 1 do line=gets(Handle) if atom(line) then exit end if line=line[1..(length(line)-1)] -- remove the line feed. TextOut(myprinterhdc,0,j,line ) j=j+charheight end while close(Handle) i=EndPage(myprinterhdc) -- eject page i=EndDoc(myprinterhdc) -- and close DeleteDC(myprinterhdc) end procedure -- hey ! no error checking------------------------------------------------------- ..with a little web-page at http://www.king.igs.net/~wolfritz