使用iframe在aspx页面中显示pdf

时间:2014-02-04 07:25:38

标签: asp.net iframe

现在,我正在使用iframe显示我的pdf。这将打开系统中的pdf阅读器以显示pdf。 我想在aspx页面中显示pdf。但是使用iframe。它应该打开一个弹出窗口,但弹出窗口应该是带有关闭按钮的aspx页面

我尝试过使用此代码,但这会在同一个页面中显示代码。我希望aspx页面只是一个关闭按钮的弹出窗口

protected void Button1_Click(object sender, EventArgs e)
{
    string FilePath = Server.MapPath("sample.pdf");
    WebClient User = new WebClient();
    Byte[] FileBuffer = User.DownloadData(FilePath);
    if (FileBuffer != null)
    {
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", FileBuffer.Length.ToString());
        Response.BinaryWrite(FileBuffer);
    }
}

0 个答案:

没有答案
相关问题