浏览器直接显示Office文档 PDF文档 如何实现(小日本急~~~)

君望永远 2011-01-07 02:19:37
RT 就是比如用户上传了一个文档 其他用户想预览一下 急~在线等
...全文
215 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
尹绵绵 2011-02-25
  • 打赏
  • 举报
回复
我也有这个问题,同求解~
阿甘1976 2011-01-10
  • 打赏
  • 举报
回复
PDF没问题
amos1989 2011-01-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 gl74gs48 的回复:]

本机必须安装对应软件,主要是使用response.setContentType
setContentType("application/pdf")打开PDF
setContentType("application/msword")打开WORD
setContentType("application/msexcel")打开EXCEL

Java code

out.clear(); ……
[/Quote]
大哥你这个是做下载。。。。。。

人家要在浏览器里面显示。。。你用一个QQ邮箱的word文档在线预览看看。。
kerioz 2011-01-10
  • 打赏
  • 举报
回复
这个打开能满足需求 不行就按上面2位说的转换
kerioz 2011-01-10
  • 打赏
  • 举报
回复
java applet解决
阿甘1976 2011-01-10
  • 打赏
  • 举报
回复
temps.write(b)应该是temps.write(buf).
阿甘1976 2011-01-10
  • 打赏
  • 举报
回复
本机必须安装对应软件,主要是使用response.setContentType
setContentType("application/pdf")打开PDF
setContentType("application/msword")打开WORD
setContentType("application/msexcel")打开EXCEL


out.clear();
response.setContentType("application/pdf");
try {
String strPdfPath = new String("D://Hibernate In Action 1.pdf");
//判断该路径下的文件是否存在
File file = new File(strPdfPath);
if (file.exists()) {
BufferedOutputStream temps = new BufferedOutputStream(response
.getOutputStream());
BufferedInputStream in = new BufferedInputStream(
new FileInputStream(strPdfPath));
byte[] buf = new byte[2048];
while ((in.read(buf)) != -1) {
temps.write(b);
temps.flush();
}

in.close();
temps.close();
} else {
out.print(strPdfPath + " 文件不存在!");
}

} catch (Exception e) {
out.println(e.getMessage());
}
amos1989 2011-01-10
  • 打赏
  • 举报
回复
楼猪这分太少了吧。。。。

介绍你一个东东 jcob.jar 他可以把word,Excel pdf转成HTML
就像QQ邮箱,如果是word文档,他就可以在线阅读
君望永远 2011-01-10
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 amos1989 的回复:]

引用 2 楼 gl74gs48 的回复:

本机必须安装对应软件,主要是使用response.setContentType
setContentType("application/pdf")打开PDF
setContentType("application/msword")打开WORD
setContentType("application/msexcel")打开EXCEL

Ja……
[/Quote]试过了,还是会出现下载对话框 IE下
君望永远 2011-01-10
  • 打赏
  • 举报
回复
用第三方类库转换成HTML的可行的,已经Coding测试OK了,但很烦。有更好的不用转换的方法么

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧