Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Writing a raw string of data to the printer.


How do I write a raw string of a data to the printer?   

    Under Win 6, you can use the SpoolFile function, or the Passthrough escape if the printer supports it. This is detailed in TI3 96 - Direct Commands to Printer - Passthrough/Escape available from the Borland web site. Under Win32, you should use WritePrinter. The following is an example of opening a printer and writing a raw string of data to the printer. Note that you must send the correct printer name, such as "HP LaserJet 5MP" for the function to succeed. You are also responsible for embedding any necessary control codes that the printer may require.

    uses WinSpool;

    procedure WriteRawStringToPrinter(PrinterName:String; S:String); var Handle: THandle; N: DWORD; DocInfo : TDocInfo ; begin if not OpenPrinter(PChar(PrinterName), Handle, nil) then begin ShowMessage('error ' + IntToStr(GetLastError)); Exit; end; with DocInfo do begin pDocName := PChar('test doc'); pOutputFile := nil; pDataType := 'RAW';

    end; StartDocPrinter(Handle, , @DocInfo ); StartPagePrinter(Handle); WritePrinter(Handle, PChar(S), Length(S), N); EndPagePrinter(Handle); EndDocPrinter(Handle); ClosePrinter(Handle); end;

    procedure TForm .Button Click(Sender: TObject); begin WriteRawStringToPrinter('HP', 'Test This'); end;

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use