Memo contents appears in text file
I have a report which works nicely when previewed and printed.
It has many labels and 1 memo.
However, when the user takes the option of outputting the report to a text
file, things go wrong.
According to the 'Developer's Guide' the contents of RichText and Memodo not
get output to a text file. Curiously I get "some" of the memo output. (This
is good as I would prefer this to happen!)
The memo contents is 4 lines. What gets output is not 0 lines as I would
expect, but lines 1, 2, 4, 1, 2, 3, 4.
I would appreciate tips on how I can block this output.
Regards, Peter Evans
It has many labels and 1 memo.
However, when the user takes the option of outputting the report to a text
file, things go wrong.
According to the 'Developer's Guide' the contents of RichText and Memodo not
get output to a text file. Curiously I get "some" of the memo output. (This
is good as I would prefer this to happen!)
The memo contents is 4 lines. What gets output is not 0 lines as I would
expect, but lines 1, 2, 4, 1, 2, 3, 4.
I would appreciate tips on how I can block this output.
Regards, Peter Evans
This discussion has been closed.
Comments
for the printer canvas' capabilities. Set the Save property to false for
the memo control and it won't get written to the text file.
If you don't want the user to ever be able to print a memo to file, then you
can set this up programatically. You could loop through all of the objects
in the report before the report prints, and check for TppMemo objects and
set their Save property to False. There is an article in the Tech-Tips
newsgroup in the Code Based thread - 'Report Object Loop.'
The best output for a memo will come when you change the report so that it
specifically is designed to print to text file. You may want to create a
duplicate report that is printed to text file, and another one for the
printer/other devices. Set TppReport.PrinterSetup.PrinterName to "Screen".
At that point you can choose the "Courier" screen font (you may have to exit
Delphi and get back in before it shows up). Set all of your text to Courier
(screen font) 12 point and everything should work.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I have a report which works nicely when previewed and printed. It has many
labels and 1 memo.
One label is on Header Band. One label is on Footer Band. Many labels and
one memo is on the
one Detail Band.
I am using demo version 6.02 for Delphi 4.
Choose File | Print to File Setup. The list of available controls for the
Detail Band only
lists the labels. It does not list the one memo. This is as it should be
according to the
"Developer's Guide". The Guide says that contents of RichText and Memo do
not get output
to a textfile.
However, the memo (or parts of it) do get output to the text file. I am
confused as to why
the memo gets output when it not one of the "Available Controls", nor does
it appear in the
list of "Selected Controls".
I tried setting the Save property to false for the memo, as you suggested.
However there is
no Save property in the "Object Inspector" that I could see. Also tried
programmatically getting
such a property using Delphi's code completion. There is no property. There
is such a property
for Label.
Is demo version 6.02 the latest version?
I did notice that the dialog "Print to File Setup" is different to the
"Developer's Guide".
My dialog has an additional edit box named "Save Length". So I suspect I
don't have the correct
version.
I welcome further advice on solving these problems.
Regards, Peter Evans
was never supported to be rendered into a text file. However, the
functionality was added to be able to support this if the text was
configured correctly so that it could map to the character grid of the file
when the text was wrapped by the report engine.
There are two text file output devices- the delimited (comma, tab...) text
file and the Report Emulation text file. The Save properties affect which
text controls are printed in the delimited text file. They have no effect on
the Report Emulation text file. The Report Emulation text file will attempt
to render as much text as it can to the text file. The only way you can
control which text prints to the file is to use the Report.BeforePrint event
and check the Report's DeviceType property and set the visibility of the
memo to false if it isn't to be generated to the Report Emulation text file.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I decided to suppress the memo to the Report Emulation Text File.
This is what I coded (in ppReport1BeforePrint(Sender: TObject)) ::-
IF ppReport1.DeviceType = ppTypes.dtReportTextFile THEN BEGIN
memoName.Visible := False {do not output}
END
ELSE
memoName.Visible := True;
The memo was still output. I then coded ::-
IF ((ppReport1.DeviceType = ppTypes.dtReportTextFile) OR
(ppReport1.DeviceType = ppTypes.dtTextFile )) THEN BEGIN
memoName.Clear;
memoName.Visible := False {do not output}
END
ELSE
memoName.Visible := True;
The memo is still output.
What am I doing wrong in the code?
Regards, Peter Evans
I decided to suppress the memo to the Report Emulation Text File.
This is what I coded (in ppReport1BeforePrint(Sender: TObject)) ::-
IF ppReport1.DeviceType = ppTypes.dtReportTextFile THEN BEGIN
memoName.Visible := False {do not output}
END
ELSE
memoName.Visible := True;
The memo was still output. I then coded ::-
IF ((ppReport1.DeviceType = ppTypes.dtReportTextFile) OR
(ppReport1.DeviceType = ppTypes.dtTextFile )) THEN BEGIN
memoName.Clear;
memoName.Visible := False {do not output}
END
ELSE
memoName.Visible := True;
The memo is still output.
What am I doing wrong in the code?
Regards, Peter Evans
getting calledand set to visible false. Make sure the event handler is
assigned if you are loading a report template .rtm. I dropped a memo in a
report and set its visibility with the following code and it didn't print to
the report text file when Memo.Visible=False:
uses
ppTypes;
procedure TForm1.Button1Click(Sender: TObject);
begin
ppReport1.Print;
end;
procedure TForm1.ppReport1BeforePrint(Sender: TObject);
begin
if (ppReport1.DeviceType = dtReportTextFile) then
ppMemo1.Visible := False
else
ppMemo1.Visible := True;
end;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I followed your lead and placed a ShowMessage() in my code ::-
ShowMessage(ShowMessage('The ppReport1.DeviceType is ' +
ppReport1.DeviceType);
This gave the following ::-
when Preview
...is Screen
when Print
...is Printer
when Report Emulation
...is Printer
So my code detected that the Property DeviceType is not being set.
I then followed your lead and did the short test program you outlined.
(It is necessary to set Property AllowPrintToFile = True)
My results were different to you. They were exactly the same as my original
project.
I then set Property DeviceType = ReportTextFile. The program worked.
It seems to me that ReportBuilder is not setting the Property DeviceType
when the user
clicks on the "Print to File" option.
Is this a bug? If not, how to I code around the problem?
Regards, Peter Evans
I am completely stuck with this problem.
original
dialog object is where the device type is getting set:
if (ppReport1.DeviceType = dtReportTextFile) then
ppMemo1.Visible := False
else if (ppReport1.PrintDialog <> nil) and
(ppReport1.PrintDialog.DeviceType = dtReportTextFile) then
ppMemo1.Visible := False
else
ppMemo1.Visible := True;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Regards, Peter Evans