Board index » delphi » File Printing in Delphi --- HOW?

File Printing in Delphi --- HOW?

Quote
richa...@pcdocs.com (Shiva Ctylyctyc) wrote:
>Hi.
>I need to allow Users to print-out the contents of a text file
>(documentation) when they press okay from my print dialog ...
>I know about including Printers in my uses clause,
>and I know about AssignPrn(variable) ...
>but somewhere along the line I am missing how to specify WHAT file I
>want to open and what mechanism to use to feed the file stream to the
>printer ....
>Can anyone help me on this? I know it's something simple, but I can't
>find the answer in the online documentation, and that's all I have at my
>disposal ...
>Shiva "Pull my Finger Component" Ctylyctyc

You don't specify which file you want to open with AssignPrn(), you
are basicly opening the device for output.  When you want to send text
to the printer you us either Write or WriteLn.

For example (from the Help File under AssignPrn):

var
  MyFile: TextFile;
begin
  AssignPrn(MyFile);
  Rewrite(MyFile);
  Writeln(MyFile, 'Print this text');
  System.CloseFile(MyFile);
end;

Brien King
bk...@primenet.com

 

Re:File Printing in Delphi --- HOW?


Hi.

I need to allow Users to print-out the contents of a text file
(documentation) when they press okay from my print dialog ...

I know about including Printers in my uses clause,
and I know about AssignPrn(variable) ...

but somewhere along the line I am missing how to specify WHAT file I
want to open and what mechanism to use to feed the file stream to the
printer ....

Can anyone help me on this? I know it's something simple, but I can't
find the answer in the online documentation, and that's all I have at my
disposal ...

Shiva "Pull my Finger Component" Ctylyctyc

Re:File Printing in Delphi --- HOW?


In article <4eb7ni$...@server.cntfl.com>, richa...@pcdocs.com says...
Quote

>Hi.

>I need to allow Users to print-out the contents of a text file
>(documentation) when they press okay from my print dialog ...

>I know about including Printers in my uses clause,
>and I know about AssignPrn(variable) ...

>but somewhere along the line I am missing how to specify WHAT file I
>want to open and what mechanism to use to feed the file stream to the
>printer ....

>Can anyone help me on this? I know it's something simple, but I can't
>find the answer in the online documentation, and that's all I have at
my
>disposal ...

>Shiva "Pull my Finger Component" Ctylyctyc

An example:

        var
                MyTextFile : Text;
                TextLine   : String;
        begin
                Assing(MyTextFile, 'c:\dir\myfielname.txt');
                Reset(MyTextFile);
                While note EOF(MyTextFile) do
                  begin
                        Readln(MyTextFile,TextLine);
                        Writeln(Prn,TexLine);
                  end;
                end;

Hopes this severs as a simple example.

Balynskee, Bob...@cris.com
Network Consulting from start to finish.

Other Threads