I am writing my first Delphi app. (using Delphi 5) after many years of
TP4,5,6. My first project is porting an old Dos (TP6) prog to Windows
(Delphi 5), and so far the
greatest problem (really the only problem) I have is printing text output. I
don't want to do anything fancy, just plain lines of text with new pages
where appropriate. Can anyone tell me the secret?
The original, pretty simple, TP6 output was sent to the printer using the
following
construction:
assign(prdevice, 'lpt1:');
rewrite(prdevice);
writeln(prdevice, 'some text');
writeln(prdevice, 'some more text');
{ etc, etc}
formfeed {see below}
writeln(prdevice, 'some more text at the top of the next page');
FormFeed {see below}
close(prdevice);
This worked a treat, with a procedure to issue a page feed:
procedure FormFeed;
begin
write(prdevice,chr(12)); {Epson printer}
end;
Now I want to do the same thing from Delphi, but using the Windows printing
facilities. According to Teixeira&Pacheco's Delphi 5 Developer's Guide, I
should be able to do much the same:
uses printers;
var myprinter: Tprinter;
.
.
.
myprinter:=printer;
assignprn(prdevice);
rewrite(prdevice);
writeln(prdevice, 'some text');
writeln(prdevice, 'some more text');
{ etc, etc}
FormFeed {see below}
writeln(prdevice, 'some more text at the top of the next page');
closefile(prdevice);
with a corresponding procedure to give the page feed:
procedure FormFeed;
begin
myprinter.newpage
end;
The problem is that myprinter.newpage inserts a complete page length. In
other words, if I print half a page of text and then call 'formfeed', the
subsequent line of text is printed halfway down the following page. Each
call to
FormFeed inserts a complete page length in this way. I have tried this with
inkjet printers attached to the local port and networked laser printers on
our Novell Network.
Can anyone end my agony please??
Neil Haughton
n.a.ha...@bigfoot.com
> greatest problem (really the only problem) I have is printing text
> output.
You are mixing low-level and high-level printer access. Stick with one
level at a time. Does sending Chr(12) not work for you?
--Bill Sparrow--
It might, but I want to give users the freedom to use any network printer
that may be attached, so I want to avoid low level methods (like chr(12))
which might always be honoured, especially on lasers and inkjets.
I shall try it. I half thought that my problem was as you suggest, but being
a novice at this Delphi lark...... I shall just have to bite the bullet and
get used to using the Printer object, I guess!
Neil Haughton
Bill Sparrow <bsparro...@cix.co.uk> wrote in message
news:memo.2000033...@bsparrow.compulink.co.uk...