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

Text layout & Memos

edited April 2002 in General
Two quick questions:


(1) I have three fields to print out in a group header band that have
varying lengths. I want to print them side-by-side with varying
lengths rather than with static lengths. I have tried setting the
left positions of the second field in the BeforePrint, AfterPrint, and
BeforeGenerate events of the group header band, but they are never
correct (doesn't do anything as far as I can tell). What do I need to
do?

(2) How do I get a memo to print to text file? I don't see any
properties for saving the text like I do in other components.


Thanks,

Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
[Please remove "nospam_" from email address to reply.]

Comments

  • edited April 2002
    1. You can set the positions of the text components in the Detail Band's
    before print event. You need to use the printer canvas to calculate the
    width of the text to know how much to shift each label. Here is an example
    that sizes and position two fields, ppDBText1 and ppDBText2 next to each
    other. Autosize is turned off on both.

    ----------------------------------------------------------------------------
    ----------------------------

    function TForm1.WidthInScreenPixels(aString: String; aFont: TFont): Integer;
    begin

    ppPrintr.ppPrinter.Canvas.Font := aFont;
    Result := ppPrintr.ppPrinter.Canvas.TextWidth(aString);

    Result := ppToMMThousandths(Result, utPrinterPixels, pprtHorizontal,
    ppPrintr.ppPrinter);
    Result := Trunc(ppFromMMThousandths(Result, utScreenPixels,
    pprtHorizontal, ppPrintr.ppPrinter));

    end;

    procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
    var
    liWidth: Integer;
    begin
    liWidth := WidthInScreenPixels(ppDBText1.Text, ppDBText1.Font);
    ppDBText1.spWidth := liWidth;
    ppDBText2.spLeft := ppDBText1.spWidth;
    liWidth := WidthInReportUnits(ppDBText2.Text, ppDBText2.Font);
    ppDBText2.Width := liWidth;
    end;

    ----------------------------------------------------------------------------
    ----------------------------

    2. Memo's can only be printed to a Report Emulation Text File. Set the
    Device Type of the report to ReportTextFile and AllowPrintToFile to True.
    When the print dialog come up a Print To File check box will be available.
    Select Report Emulation Text File from the drop down menu.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.