Solved

Problems printing a simple textfile from Delphi

Posted on 1997-07-22
5
226 Views
Last Modified: 2010-04-04
This is the first time I try to do this. Printing a textfile from a Delphi program. I'm not sure if I'm doing it the right way. I read the textfile line by line and copy the read line in a variable (string) then I call the method printer.canvas.textout(x,y,string) in which x and y are variables updated elsewhere in the program. The debugger shows that the string is filled with lines from the textfile,but the method don't seem to work properly,because all I get after sending the job with printer.enddoc is an empty page. The debugger shows that the canvas is not updated by the method.  I suppose I forgot something. Any body can help me out?
0
Comment
Question by:lizzzard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Expert Comment

by:icampbe1
ID: 1339464
Put a PrintDialog on your form and then:

USES Printers;

IF PrintDialog1.Execute THEN BEGIN
   WITH Printer DO BEGIN
      BeginDoc;
      ....
      canvas.TextOut( x, y, str );
      .....
      EndDoc;
      END;  {Of with printer}
   END;

This should work for you.
Cheers,
Ian C.

0
 

Author Comment

by:lizzzard
ID: 1339465
What Icambe suggested is already the way I coded it. That's why I can't figure out why my printer doesn't print anything. (And eh.. it's not that I'm out of ink.)
0
 

Expert Comment

by:M_Hoeper
ID: 1339466
Please send your whole print code.
0
 
LVL 6

Accepted Solution

by:
rcastle earned 50 total points
ID: 1339467
What IanC suggested should work.  Please send your code to
rcastle@reell.com

Here is my spin on it

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,printers;

type
  TForm1 = class(TForm)
    Button1: TButton;
    PrintDialog1: TPrintDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
IF PrintDialog1.Execute THEN
BEGIN
 WITH Printer DO
 BEGIN
  BeginDoc;
  canvas.TextOut( 1, 1, 'hello' );
  EndDoc;
 END; {Of with printer}
END;
end;

end.

Thanx
0
 

Author Comment

by:lizzzard
ID: 1339468
Ok,problem solved. Thx
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month5 days, 16 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question