JAVA打开路径下的word文档_用java打开paf、word..文件

1-使用 Runtime.getRuntime().exec("C:\\Program Files (x86)\\Adobe\\Reader 11.0\\Reader\\AcroRd32.exe E:\\11.pdf");就可以

前面为打开文件的程序路径、后面为文件的路径。

2-jsp上显示pdf

01.

02.pageEncoding="ISO-8859-1"%>

03.

04.String path =request.getContextPath();05.String basePath = request.getScheme() + "://"

06. + request.getServerName() + ":" +request.getServerPort()07. + path + "/";08.%>

09.10.

11.

12.

13.

14.

15.

16. out.clear();17. out =pageContext.pushBody();18. response.setContentType("application/pdf");19.20. try{21. String strPdfPath = new String("D://200701010001.PDF");22. //判断该路径下的文件是否存在

23. File file = newFile(strPdfPath);24. if(file.exists()) {25. DataOutputStream temps = newDataOutputStream(response26. .getOutputStream());27. DataInputStream in = newDataInputStream(28. newFileInputStream(strPdfPath));29.30. byte[] b = new byte[2048];31. while ((in.read(b)) != -1) {32. temps.write(b);33. temps.flush();34. }35.36. in.close();37. temps.close();38. } else{39. out.print(strPdfPath + " 文件不存在!");40. }41.42. } catch(Exception e) {43. out.println(e.getMessage());44. }45.%>

46.

47.

48.

49.

3.用object标签使用pdf插件嵌入ie中

01.

02.

03.

04.

05.

06.

Checking if Acrobat Reader installed (IE4+)...

07.

09. document.all [10. document.all.PDFNotKnown ? "IfNoAcrobat" : "IfAcrobat"

11. ] .style.display = "block";12. //-->

13.

14.

15.

16. Cannot determine ifyou have Acrobat Reader (or the full Acrobat)17. installed (because JavaScript is unavailable or18. turned off).19.

20.

24.

25.

26.

27.

29.

30.

31.

32.33.

34.35.

36.37.

38.39.

40.

41.

42.

43.

4-在网页中直接显示pdf格式的文件

Html代码

标准浏览器中:

Java代码

alt : test.pdf

alt : test.pdf

IE7.0以上版本的浏览器中可用如下方法,低版本的IE会显示两个Object区域

Java代码

alt : test.pdf

alt : test.pdf

低版本浏览器中的处理方法1:

Java代码

alt : Adobe Reader.pdf

低版本浏览器中的处理方法2:通过CSS控制显示隐藏

Html代码/* hides the second object from all versions of IE */

* html object.hiddenObjectForIE { display: none; }

/* display the second object only for IE5 Mac */

/* IE Mac \*//*/

* html object.hiddenObjectForIE { display: inline; }

/**//* hides the second object from all versions of IE */* html object.hiddenObjectForIE { display: none; }/* display the second object only for IE5 Mac *//* IE Mac \*//*/* html object.hiddenObjectForIE { display: inline; }/**/

Html代码

alt : test.pdf

据说用 itext 或者 pdf Rentender 也可以实现,没有实践 留待下次细说。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值