Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Text To Printer, Example 107

edited August 2001 in General
Hi All:

Report Builder comes with a demo, #107, that illustrates how to "print" a
report to a text file. Does anyone have example code on the best way to send
this text file to a printer?

Thanks,
Mike

Comments

  • edited August 2001
    -----------------------------------------------
    Tech Tip: Send TextFile to Printer
    -----------------------------------------------

    I designed a application that exports the report to a .txt
    file using ReportTextFile device.

    How can I Send the text file to the printer?

    The following procedure will send the .txt file to
    the printer using Delphi's TPrinter object.



    uses
    Printers;


    procedure SendTextFileToPrinter(aFileName: String);
    var
    lsLines: TStringList;
    lOutputFile: TextFile;
    liIndex: Integer;
    begin

    lsLines := TStringList.Create;

    try
    lsLines.LoadFromFile(aFileName);

    AssignPrn(lOutputFile);
    Rewrite(lOutputFile);

    for liIndex := 0 to lsLines.Count-1 do
    Writeln(lOutputFile, lsLines[liIndex]);

    CloseFile(lOutputFile);

    finally
    lsLines.Free;
    end;


    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.