如何从数据库打开pdf文件到新窗口 [英] How to open pdf file from database to new window

查看:56
本文介绍了如何从数据库打开pdf文件到新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void ShowDocument(string fileName, byte[] fileContent)
    {
        //Split the string by character . to get file extension type
        string[] stringParts = fileName.Split(new char[] { '.' });
        string strType = stringParts[1];
        Response.Clear();
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
        //Set the content type as file extension type
        Response.ContentType = strType;
        //Write the file content
        this.Response.BinaryWrite(fileContent);
        this.Response.End()    



现在如何将此文件定位到新窗口浏览器


now how to target this file to new window of browser

推荐答案





Hi,

Response.Write("<script>");
Response.Write("window.open('[Your PDF path]', '[Tab Name]');");
Response.Write("</script>");


// Try this, it is working perfect in my project...

Response.Flush();
Response.Clear();

Response.AppendHeader("content-disposition", "inline;filename=yourpdfname.pdf");
Response.ContentType = "application/pdf";

Response.BinaryWrite(fileContent);
Response.Flush();


Google [ ^ ]今天到底真的坏了吗?之前已经多次讨论过这个问题。
Is Google [^]really broken at your end today? This has been discussed/done so many times before.


这篇关于如何从数据库打开pdf文件到新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆