项目场景:.net6 webapi 使用spire.doc 对 word 模板编辑,并返回前台 pdf 文件流
问题描述
doc.SaveToStream(pdfDocument, FileFormat.PDF); pdfDocument 为stream,直接返回出去,出现错误timesout错误。
代码如下
public MemoryStream EditTemplateDoc(List list,string reportTitle)
{
var doc = new Document(_templatePath);
var table = doc.Sections[0].Tables[0];
for (var n = 1; n < list.Count; n++)
table.Rows.Add(table.Rows[2].Clone());
foreach (var item in list )
{
var index = list.IndexOf(item);//下标从0开始
var cells = table.Rows[index + 2].Cells;
foreach (TableCell cell in cells)
{
cell.Paragraphs[0].Text = cell.Paragraphs[0].Text.Replace(TableCellBay, item.Breaker.Bay);
cell.Paragraphs[0].Text = cell.Paragraphs[0].Text.Replace(TableCellCircuit, item.Breaker.Circuit);
cell.