frxRichView contents set font size before print?

edited 5:45AM in FastReport VCL 5
I am making a label report for deli items that includes item description, price UPC, and ingredients list.
The ingredients list is a widestring field of up to 1000 characters. This field is tied to a data bound RTF editor to allow user to format ingredients, say to bold any allergens.
I want to ignore the font size in the field's RTF formatting code and print the contents of the widestring in a 6 pt font, so that it fits on the label.
Is there a way I can do this on the RichView OnBeforePrint event? Thank you.

Comments

  • gpigpi
    edited 5:45AM
    From ticket 441316:
    procedure Rich1OnBeforePrint(Sender: TfrxComponent); 
    var s: string; 
    begin 
    s := Rich1.RichEdit.Lines.Text; 
    Rich1.RichEdit.Lines.Clear; 
    Rich1.RichEdit.Lines.Text := s; 
    end;
    
  • edited June 2017
    gpi wrote: »
    From ticket 441316:
    procedure Rich1OnBeforePrint(Sender: TfrxComponent); 
    var s: string; 
    begin 
    s := Rich1.RichEdit.Lines.Text; 
    Rich1.RichEdit.Lines.Clear; 
    Rich1.RichEdit.Lines.Text := s; 
    end;
    

    The code executed but it did not change the font size of the text. Paul, if you wish, we can correspond on the forum instead of support ticket. I planned to post the final solution here anyhow.
  • gpigpi
    edited 5:45AM
    This code just clear RTF formatting. To set TRichEdit font size do in the Delphi
    TfrxRichView(frxReport1.FindObject('Rich1')).RichEdit.SelectAll;
      TfrxRichView(frxReport1.FindObject('Rich1')).RichEdit.SelAttributes.Size := 20;
      frxReport1.ShowReport();
    
  • gpigpi
    edited 5:45AM
    wrote:
    if you wish, we can correspond on the forum instead of support ticket
    Support tickets have high priority
  • edited June 2017
    For anyone interested:

    From Support
    You can't to change TfrxRichView font side in the script. In the Delphi's code only
    TfrxRichView(frxReport1.FindObject('Rich1')).RichEdit.SelectAll;
      TfrxRichView(frxReport1.FindObject('Rich1')).RichEdit.SelAttributes.Size := 6;
    


    I added TfrxRichObject component to the data module where TfrxReport rxAnyFastReport lives and added frxRich to my units Uses list..
    The report runs but font is not changed to 6 pt. IncludeIngredients is true, breakpoint showed code entered the if block. I will probably
    not use RTF and go back to using a memo object.

    dmPBData.frxAnyFastReport.LoadFromFile(RptPath);
    if includeIngredients then
    begin
    TfrxRichView(dmPBData.frxAnyFastReport.FindObject('Rich1')).RichEdit.SelectAll;
    TfrxRichView(dmPBData.frxAnyFastReport.FindObject('Rich1')).RichEdit.SelAttributes.Size := 6;
    end;
    Screen.Cursor := crDefault;
    dmPBData.frxAnyFastReport.ShowReport();
    end

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.