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 abort a print job and print to a file instead 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
07-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
43
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to abort a print job and print to a file instead

Answer:

Print to file:

1   uses
2     printers;
3   
4   {$R *.DFM}
5   
6   procedure StartPrintToFile(filename: string);
7   var
8     CTitle: array[0..31] of Char;
9     DocInfo: TDocInfo;
10  begin
11    with Printer do
12    begin
13      BeginDoc;
14      { Abort job just started on API level. }
15      EndPage(Canvas.handle);
16      Windows.AbortDoc(Canvas.handle);
17      { Restart it with a print file as destination. }
18      StrPLCopy(CTitle, Title, SizeOf(CTitle) - 1);
19      FillChar(DocInfo, SizeOf(DocInfo), 0);
20      with DocInfo do
21      begin
22        cbSize := SizeOf(DocInfo);
23        lpszDocName := CTitle;
24        lpszOutput := PChar(filename);
25      end;
26      StartDoc(Canvas.handle, DocInfo);
27      StartPage(Canvas.handle);
28    end;
29  end;
30  
31  procedure TForm1.Button1Click(Sender: TObject);
32  begin
33    StartPrintToFile('C:\temp\temp.prn');
34    try
35      Printer.Canvas.TextOut(100, 100, 'Hello World.');
36    finally
37      Printer.endDoc;
38    end;
39  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