fastreport 自动缩小字体以填允

来源:互联网 发布:淘宝买家如何删除差评 编辑:程序博客网 时间:2024/04/29 02:17
1.
procedure Memo8OnBeforePrint(Sender: TfrxComponent);
begin
  while ((TfrxMemoView(Sender).CalcHeight-TfrxMemoView(Sender).LineSpacing)-TfrxMemoView(Sender).Height>0) do
  begin
    TfrxMemoView(Sender).Font.Size := TfrxMemoView(Sender).Font.Size-5;
  end;
end;


2.
begin
     per:=1.4;
     xy:=[adoquery1."xy"];
     len:=length(xy);
     width:=memo1.width;
     fs:= Round(width  / len * per) ;
     memo1.font.size:=fs;
     memo1.memo :=xy;
     memo2.memo:= str(width);
end


增加字体调整模式
TfrxScaleFontSize = (sfsWidth, sfsHeight, sfsNone);
增加TfrxMemoView属性
property ScaleFontSize;
增加TfrxCustomMemoView属性
property ScaleFontSize: TfrxScaleFontSize read FScaleFontSize write FScaleFontSize default sfsNone;

procedure TfrxCustomMemoView.BeforePrint;
begin
  inherited;
  if not IsDataField then
    FTempMemo := FMemo.Text;

  case FScaleFontSize of
    sfsNone: ;

    sfsWidth:
      if not WordWrap and not AutoWidth then //按宽度调整时--自动换行时不可用 ;  自动宽度时不可用
        while (CalcWidth - Width > 0) do
          Font.Size := Font.Size - 1;

    sfsHeight:
      if (StretchMode = smDontStretch) then //伸展时不能按高度调整
        while ((CalcHeight - LineSpacing) - Height > 0) do
          Font.Size := Font.Size - 1;
  end;
end;
0 0
原创粉丝点击