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

TppReportTextFileDevice Advise

edited December 2001 in General
Hello All:

I have reviewed Demo # 107 in an attempt to print a report using
TppReportTextFileDevice.

My report is about 18 inches long and 11 inches wide. Under windows 2000
I cannot get it to print using the normal ppReport1 component. It prints
great under Windows 98 using ppReport1.

My code to print the report is as follows:

ppReport1.AllowPrintToFile:=True;
ppReport1.TextFileName:='C:\_NH\Temp.txt';
ppReport1.DeviceType:='dtPrinter';
ppReport1.ShowPrintDialog:=True;
if (ppReport1.FileDevice <> nil) and
(ppReport1.FileDevice is TppReportTextFileDevice)then
begin
lDevice := TppReportTextFileDevice(ppReport1.FileDevice);
{132 characters per line, 132 lines per page}
lDevice.CharacterGrid(132, 132);
end;
ppReport1.Print;


Questions:

1) Is this code doing anything different than a simple ppReport1.Print
( it appears to work ) ???

2) Does this bypass the printer driver ???

3) In order to get the length of the form to work, I used the
lDevice.CharacterGrid(132, 132) command. What are the limitations of the
parameters - specifically the length in lines ( ie is it limited in length
by printer driver parameters ) ???

4) Is there a way for me to eliminate using the printshow dialog using
the TppTextFIleDevice method ( can I simply make ShowPrintDialog=False ) ???

Thank you very much.



Neil Huhta
Profit Monster Data Systems LLC

Comments

  • edited December 2001

    1. You need to move the following code to the Report.BeforePrint event.
    The Report.FileDevice will return nil until it is created by the
    Report.Print method.

    if (ppReport1.FileDevice <> nil) and
    (ppReport1.FileDevice is TppReportTextFileDevice)then
    begin
    lDevice := TppReportTextFileDevice(ppReport1.FileDevice);
    {132 characters per line, 132 lines per page}
    lDevice.CharacterGrid(132, 132);
    end;


    2. If you want to set Report.ShowPrintDialog to False, then you need set
    the Report.DeviceType to dtReportTextFile:

    uses
    ppTypes;

    Report.DeviceType := dtReportTextFile;

    3. The Report.PrinterSetup properties for margins, paper size etc. are
    always used by RB. And the printer driver is always used to measure text
    etc - unless you set Report.PrinterName to 'Screen'.

    4. When you send the .txt file to the printer then the printer driver
    will be used.






    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.