C# 如何通过ashx的iTextsharp导出水印pdf?

C# 如何通过ashx的iTextsharp导出水印pdf?,c#,pdf,itext,watermark,ashx,C#,Pdf,Itext,Watermark,Ashx,我正在使用iTextsharp制作ashx下载水印PDF。 结果文件为空,没有内容。但是页面大小是正确的。 我怎样才能解决这个问题 context.Response.Clear(); context.Response.AddHeader("Content-Disposition", "attachment;filename=pdfexample.pdf"); context.Response.ContentType = "a

我正在使用iTextsharp制作ashx下载水印PDF。 结果文件为空,没有内容。但是页面大小是正确的。 我怎样才能解决这个问题

            context.Response.Clear();
            context.Response.AddHeader("Content-Disposition", "attachment;filename=pdfexample.pdf");
            context.Response.ContentType = "application/octet-stream";
            context.Response.OutputStream.Write(memoryStream.GetBuffer(), 0, memoryStream.GetBuffer().Length); //, memoryStream.GetBuffer().Length
            context.Response.OutputStream.Flush();
            context.Response.OutputStream.Close();
            context.Response.Flush();
            context.Response.End();