zoukankan      html  css  js  c++  java
  • 如何用C# 输出pdf文件流在页面上显示

    1、首先客户端需要安装Adobe Reader这个东西

    2、前台html代码如下 :

         <object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="100%" height="1050"

            border="0">
            <param name="_Version" value="65539">
            <param name="_ExtentX" value="20108">
            <param name="_ExtentY" value="10866">
            <param name="_StockProps" value="0">
            <param name="SRC" value="<%=_pdf %>">

        </object 

       这个_pdf变量是后台的一个全局变量_pdf = "Handler.ashx?Id=" + _Id + "&Name=" + _name;

    3、在Hander中抓取pdf ,_arr为byte流(byte[])

     var _arr = service.GetDocumentContents(_Id); 


                if (!Equals(null, _arr) && _arr.Length > 0)
                {
                    try
                    {
                        context.Response.ContentType = "application/pdf";
                        context.Response.AddHeader("Content-Disposition""attachment;  filename=" + HttpUtility.UrlEncode(_name, System.Text.Encoding.UTF8));
                        context.Response.BinaryWrite(_arr);
                        context.Response.Flush();
                        context.Response.End();
                    }
                    catch 
                    {
                        context.Response.Close();
                    }
                    finally
                    {
                        context.Response.Close();
                    }

                }

      

  • 相关阅读:
    POJ2828
    Docker容器修改端口映射
    CentOS 7使用ISO镜像配置本地yum源
    Windows 自带的 Linux 子系统
    vue富文本编辑器插件vue-quill-editor使用
    修改docker容器存放位置
    Linux 硬盘相关操作
    centos7基础相关
    ubuntu-k8s搭建
    redhat 6.6 离线docker
  • 原文地址:https://www.cnblogs.com/oula_king/p/2353593.html
Copyright © 2011-2022 走看看