Solved

Print ASCII Files in Delphi 2

Posted on 1997-05-29
2
252 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

12 Experts available now in Live!

Get 1:1 Help Now