我已将 PDF 文档保存到我的 PDF 文件夹中。我创建了一个函数,其职责是将 PDF 加载到PdfDocument
类中,添加一些样式runtime
,将其保存为临时文件并在WebClient
. 我的逻辑工作得很好。我想消除将其保存为临时文件。我想直接预览而不保存,可以吗?我在网上搜索,但没有找到任何好的来源。以下是我的代码:
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("MyFile.pdf");
pdf.SaveToFile("ModifiedMyFile.pdf"); // Eliminate this part
WebClient User = new WebClient();
Byte[] FileBuffer = User.DownloadData("ModifiedMyFile.pdf");
if (FileBuffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", FileBuffer.Length.ToString());
Response.BinaryWrite(FileBuffer);
}