Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to send a raw string to the printer Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-Oct-02
Category
Reporting /Printing
Language
Delphi 5.x
Views
81
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Maarten de Haan

How to send a raw string to the printer

Answer:

procedure PrintRawStr(const S: ANSIString);

1   uses WinSpool, Printers;
2   
3   var
4     sDefaultPrinter: string;
5     Handle: THandle;
6     dwN: DWORD;
7     diDocInfo1: TDocInfo1; // Uses WinSpool
8     bP: BYTE;
9   
10  begin
11    // Get the default printer or the printer choosen in the Printer Setup Dialog
12    // if you have one in the application
13    if Printer.Printers.Count > 0 then
14    begin
15      sDefaultPrinter := Printer.Printers[Printer.PrinterIndex]; // Uses Printers
16      //uses Printers, get default printer
17      bP := Pos(' on ', sDefaultPrinter);
18      if bP > 0 then
19        sDefaultPrinter := Copy(sDefaultPrinter, 1, bP - 1);
20    end
21    else
22      Exit; // No printers installed on this system...
23  
24    if not OpenPrinter(PChar(sDefaultPrinter), Handle, nil) then
25    begin
26      case GetLastError of
27        87: ShowMessage('Printer name does not exists.');
28      else
29        ShowMessage('Error ' + IntToStr(GetLastError)); // Uses Dialogs
30      end;
31      Exit; // Cannot find the printer
32    end;
33  
34    with diDocInfo1 do
35    begin
36      pDocName := PChar('Print job raw'); // Will be seen in printer spooler
37      pOutputFile := nil;
38      pDataType := 'RAW';
39    end;
40  
41    StartDocPrinter(Handle, 1, @diDocInfo1);
42    StartPagePrinter(Handle);
43    WritePrinter(Handle, PChar(S), Length(S), dwN);
44    EndPagePrinter(Handle);
45    EndDocPrinter(Handle);
46    ClosePrinter(Handle);
47  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC