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

Forcing TppRichText to only break across a page at a bullet

edited May 2011 in General
I have a TppRichText with KeepTogether set to false. In this setup, it
obviously will continue on to the next page if it's too long. The
problem is that the text in the TppRichText is formatted using bulleted
paragraphs, and having the page break in the middle of the paragraph is
a little messy.

Is there any way to force the page break to be between two bulleted
paragraphs, instead of in the middle of one of them?

Thanks,

Jason

Comments

  • edited May 2011
    Hi Jason,

    ReportBuilder does not have a built-in feature to keep each bullet point
    of a RichText together. You might try separating each bullet point into
    a single RichText file/record and then keeping the entire RichText
    component together.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2011
    Thanks, Nico.

    Here's what I'm trying to do to work around this. But this code always
    just makes no RTF show up for records where the rtf is over 700
    characters. What can I do to make these dynamically-created TppRichText
    components show up with the new text?

    procedure TdlgCompile.rtfDetailsGetRichText(Sender: TObject; var Text:
    string);
    var
    s, opt: string;
    i, i2: Integer;
    re, reTmp: TppRichText;
    sndr: TppDBRichText;
    ms: TMemoryStream;
    mmo: TMemo;
    begin
    sndr := TppDBRichText(Sender);

    opt := dm.tblOutput.FieldByName('Option').AsString;

    re := TppRichText.Create(nil);
    ms := TMemoryStream.Create;
    mmo := TMemo.Create(nil);
    try
    re.Visible := True;
    re.left := 100;
    re.top := 100;
    re.width := 6.0;
    re.height := 500;

    mmo.Parent := dlgCompile;
    mmo.Visible := True;
    mmo.WordWrap := False;
    mmo.left := 50;
    mmo.top := 50;
    mmo.width := 2500;
    mmo.height := 500;
    mmo.font.Name := 'Arial';
    mmo.font.Size := 11;

    TMemoField(dm.tbloutput.FieldByName('RTFDetails')).SaveToStream(ms);
    ms.Position := 0;

    re.LoadFromRTFStream(ms);
    mmo.Lines.Text := re.PlainText;

    if Length(mmo.Lines.Text) > 700 then
    begin
    i2 := 0;
    for i := 0 to mmo.Lines.Count - 1 do
    begin
    if not Assigned(FindComponent('rtf' + opt + IntToStr(i2))) then
    begin
    reTmp := TppRichText.Create(rptOutput.Owner);
    reTmp.Name := 'rtf' + opt + IntToStr(i2);
    reTmp.Tag := 2011;
    reTmp.Band := sndr.Band;
    reTmp.Left := sndr.Left;
    reTmp.Region := rgnBand;
    reTmp.Width := sndr.Width;
    reTmp.Stretch := True;
    reTmp.KeepTogether := True;
    if i = 0 then
    reTmp.ShiftRelativeTo := sndr
    else
    reTmp.ShiftRelativeTo := TppRichText(FindComponent('rtf' +
    opt + IntToStr(i - 1)));
    end else
    reTmp := TppRichText(FindComponent('rtf' + opt + IntToStr(i2)));

    reTmp.Text := mmo.Lines[i];
    i2 := i2 + 1;
    end;
    end else
    begin
    Text := re.RichText;
    end;

    finally
    mmo.Free;
    ms.Free;
    re.free;
    end;

    end;
  • edited May 2011
    Hi Jason,

    Have you traced the code below? Is the TppDBRichText component created
    actually receiving valid RTF data?

    I suggest simplifying what you have below then incrementally adding
    functionality. Start with simply creating a TppRichText in code and
    adding text to it. Then try the same thing but copy text from a
    DBRichText component to it. Once you have this working, you should be
    able to move forward more easily.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.