Solved

Print ASCII Files in Delphi 2

Posted on 1997-05-29
2
255 Views
Last Modified: 2010-04-06
Hello, my name is Angel and I have a problem. I don't know how I can print an ASCII file in Delphi after press a button. I don't want use TPrinter component. I like that result was identical that I wrote in MS-DOS 'print autoexec.bat'.

Thanks.

My e-mail is sa328@blues.uab.es
0
Comment
Question by:Anglaf
2 Comments
 
LVL 4

Expert Comment

by:StevenB
ID: 1336647
 Why don't you want to use the TPrinter? It is the easiest way and any other technique will involve doing much the same kind of thing, but in a more complicated fashion. Explain why you can't use TPrinter and I'll try to help.
0
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
ID: 1336648
This will do for 50 pt:

procedure TMainForm.Button12Click(Sender: TObject);
var
  t, lpt: TextFile;
  line  : string;
begin
  if OpenDialog.Execute then try
    AssignFile(t, OpenDialog.Filename);
    AssignFile(lpt, 'LPT1');
    FileMode := 0;
    Reset(t);
    Rewrite(lpt);
    while not EOF(t) do begin
      ReadLn(t, line);
      WriteLn(lpt, line);
    end;
    Write(lpt, #4); // end of transmission
    CloseFile(lpt);
  except
    // trap errors here
  end;
end;

-= or simply =-

procedure TMainForm.Button13Click(Sender: TObject);
begin
  Winexec('cmd /c print main.txt', SW_HIDE);
end;

/// John

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 93
Delphi XE2 application frozen on Windows 10 10 277
Convert Jpg /PNG To GIF 5 120
Communication Between RC4 Delphi <-> PHP 3 100
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now