0
public MemoryStream PdfGeneration(Model model)
{
string path = HttpContext.Current.Server.MapPath("test.pdf");
path = path.Replace("\\api", "");
FileStream fs = new FileStream(path, FileMode.Create);
doc.SaveToStream(fs);
MemoryStream ms = new MemoryStream();
ms.SetLength(fs.Length);
fs.Read(ms.GetBuffer(), 0, (int)fs.Length);
ms.Flush();
fs.Close();
return ms;
}
PS:我不想从磁盘读取文件,它必须在内存中处理。如何使用Spire PDF将文件保存并加载到内存流C#
所以我在这里使用Spire PDF
作为生成器,我需要将它保存到内存流并作为附件发送到邮件。