Solved

printing files

Posted on 2000-02-17
3
137 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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
Convert a string into a TDateTime 5 80
Dynamically Created Query 3 80
Delphi android app hide keyboard 3 82
delphi popmenu non latine charcters 3 48
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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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