Ejemplo n.º 1
0
    private void WritePdfToResponse(string fileName)
    {
        object uploadedFileBytes = Page.Session["UploadedFile"];

        if (uploadedFileBytes == null)
        {
            return;
        }
        MemoryStream stream = MemoryStreamHelper.FromBytes(uploadedFileBytes);

        Page.Session["UploadedFile"] = null;
        if (stream == null)
        {
            return;
        }
        stream.WriteTo(Page.Response.OutputStream);
        Page.Response.ContentType    = "application/pdf";
        Page.Response.HeaderEncoding = System.Text.Encoding.UTF8;
        Page.Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}.pdf", Path.GetFileNameWithoutExtension(fileName)));
        Page.Response.End();
    }