Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

printing files

Posted on 2000-02-17
3
Medium Priority
?
139 Views
Last Modified: 2010-04-04
How can i print file on printer that runs under win95 or winnt,how to print text at all on printer.(textualfile,bmp)
is there some parametars that are good to know when printing.I would like an example.I know this answer will give you only 15 points,but please help.I am just an ordinary begginer.Thank you very much.
                   M@rko
0
Comment
Question by:marko_svaljek
[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
3 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 30 total points
ID: 2532035
To print a standard text file try doing the following:

Printer.BeginDoc;
lh := Printer.Canvas.TextHeight('Aj');
max_lines := Printer.PageHeight DIV lh;
iCount := 0;

AssignFile(data_in, <filename>);
Reset(data_in);
WHILE NOT(EOF(data_in))
DO
BEGIN
  READLN(data_in, text_str);
  Printer.Canvas.TextOut(0, lh * iCount, text_str);
  iCount := iCount + 1;
  IF iCount > max_lines
  THEN
  BEGIN
    iCount := 0;
    Printer.NewPage;
  END;
END;
Printer.EndDoc;
CloseFile(data_in);

What this will do is simply load lines of text from your text file and send them to the printer. Delphi handles all of the printer side of things for you.

Be warned, this example doesn't do anything like text wrapping or the like but does show you how to easily get text onto the printed page, how to position text on the page, how to create a print job, and how to print over several pages.

If you need any more then just ask.

The Neil

PS Make sure that you add the Printers unit to your USES list
0
 
LVL 6

Expert Comment

by:edey
ID: 2532230
or

with TRichedit.create(application) do
begin
//set dimensions
     LoadFromFile(file_name);
     print(some_caption);
     free;
end;


and you can use the TPrinter object to set page size & margins (or have the user do it with a TPrinterSetup dialog)


GL
Mike
0
 

Author Comment

by:marko_svaljek
ID: 2535844
Thank you very much!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

730 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