Solved

printing files

Posted on 2000-02-17
3
135 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
3 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 10 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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