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
作爲生成器,我需要將它保存到內存流並作爲附件發送到郵件。