Это работает в Chrome и Firefox, но IE8 ничего не отображает ... Когда я попробовал один и тот же код при нажатии кнопки веб-форм, он работает во всех трех браузерах.
Как мне заставить это работать в IE8?
public class ShowPDF : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// create PDF document
var document = new PdfDocument();
var page = document.AddPage();
var font = new XFont("Verdana", 20, XFontStyle.Bold);
var gfx = XGraphics.FromPdfPage(page);
gfx.DrawString("Hello, World!", font
, PdfSharp.Drawing.XBrushes.Black
, new PdfSharp.Drawing.XRect(0, 0, page.Width, page.Height)
, PdfSharp.Drawing.XStringFormats.Center
);
// Send PDF to browser
var stream = new System.IO.MemoryStream();
document.Save(stream, false);
context.Response.Clear();
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("content-length", stream.Length.ToString());
context.Response.BinaryWrite(stream.ToArray());
context.Response.Flush();
stream.Close();
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}