我设法使用自定义选项卡间距导出了格式化的 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。