Solved

printing files

Posted on 2000-02-17
3
132 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

13 Experts available now in Live!

Get 1:1 Help Now