如何在asp.net页面上查看pdf或word文件 [英] How to view pdf or word file on asp.net page

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

问题描述

早上好

实际上,我无法在asp.net网络表单上查看PDF或Word文件.

首先我正在服务器上上传文件.

第二个我将在网格视图中看到所有文件名,当我选择特定文件时,该文件应以新的Web形式打开.

因此,请帮助我解决此问题.

Hi good morning

Actually I am not able to view the PDFs or word file on asp.net web-form.

First I am uploading the file on server.

Second I will see all the file names in grid-view and when I select the particular file than that file should be open in new web-form.

So please help me out to solve this problem.

推荐答案

只需检查一下:


未安装Acrobat Reader的ASP.NET PDF Viewer用户控件客户端或服务器 [ ^ ]
Just Check :


ASP.NET PDF Viewer User Control Without Acrobat Reader Installed on Client or Server[^]


嗨 您可以使用两种方式在Web表单上显示pdf

1)
使用System.Net;

字符串pdfPath = Server.MapPath(〜/SomePDFFile.pdf");
WebClient客户端=新的WebClient();
Byte [] buffer = client.DownloadData(pdfPath);
Response.ContentType =应用程序/pdf";
Response.AddHeader("content-length",buffer.Length.ToString());
Response.BinaryWrite(buffer);

2)
Response.Redirect(〜/somePDFFile.pdf");

祝你好运
快乐编码
Hi using two way u can show pdf on web Form

1)
using System.Net;

string pdfPath = Server.MapPath("~/SomePDFFile.pdf");
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(pdfPath);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);

2)
Response.Redirect("~/somePDFFile.pdf");

Best Luck
happy Coding


这篇关于如何在asp.net页面上查看pdf或word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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