在asp.net中打开一个pdf文件 [英] open a pdf file in asp.net

查看:361
本文介绍了在asp.net中打开一个pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中打开pdf文件,如网站?

How to open a pdf file in asp.net like a web site ?

推荐答案

如果您的目的是将PDF内容放入浏览器页面中可以创建一个ASPX页面并将其添加到它。



If your aim is to just put the PDF content into the browser page you can create an ASPX page and add this to it.

protected void Page_Load(object sender, EventArgs e)
{
    byte[] pdf = System.IO.File.ReadAllBytes(@"C:\PDFs\MyPDF.pdf");
    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "filename=MyPDF.pdf");
    Response.BinaryWrite(pdf);
}


这篇关于在asp.net中打开一个pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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