【问题标题】:Delphi - FastReport send contents of richEditDelphi - FastReport 发送richEdit的内容
【发布时间】:2021-03-05 07:40:38
【问题描述】:

我已尝试将 Rich Edit 的文本发送到 FastReport,以便将输出保存为 PDF。

我使用了 OnGetValue

    procedure TfrmEmediaInvoice.frxReport1GetValue(const VarName: string;
  var Value: Variant);
begin
 value := redInvoice.Text;
end;

问题是它没有保留标签 #9。

谁能告诉我将富编辑内容打印或导出为 PDF 的正确方法。 谢谢

【问题讨论】:

  • 澄清一下,我可以通过 OnGetValue 事件将 redInvoice 打印到 FastReport。但是,输出不会保留在 RichEdit 组件中设置的制表符间距。

标签: delphi pdf fastreport richedit


【解决方案1】:

我设法使用自定义选项卡间距导出了格式化的 Rich Edit 组件的内容。

在 FastReports 中,我使用了 tfrxRichView 框。这个问题是当您通过 OnGetValue 事件将其发送到 FastReports 时,它会丢失其自定义选项卡间距。

我通过将 Rich Edit 的内容保存到 .rtf 文件解决了这个问题

redInvoice.Lines.SaveToFile('Invoice - ' + sInvoice + '.rtf');

然后我在 FastReports tfrxRichView 框中打开了 .rtf 文件。

RichView := TfrxRichView(frxReport1.FindObject('Rich1'));
  if RichView = nil then
    Exit;
  Stream := TMemoryStream.Create;
  try
    Stream.LoadFromFile('Invoice - ' + sInvoice + '.rtf');
    SetLength(Str, Stream.Size);
    Stream.Read(Str[1], Stream.Size);
    RichView.RichEdit.Text := Str;
  finally // wrap up
    Stream.Free;
  end;    // try/finally

最后,我将其导出为 PDF。 “ExportPDF”是我用来保存冗长的导出代码的方法。

 frxUserDataSet1.RangeEnd := recount;
 frxUserDataSet1.RangeEndCount := redInvoice.Lines.Count;

  try
  ExportPDF;
  Showmessage('Invoice published.');
  except
  showmessage('Error - Invoice not published.');
  end;

是的,您需要在 FastReports 的 MasterData 部分使用 frxUserDataSet。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-26
    • 1970-01-01
    • 2014-05-06
    • 1970-01-01
    相关资源
    最近更新 更多