且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Java Swings中打开PDF文件

更新时间:2023-11-26 11:20:04

1。使用注册表类确定用于打开.pdf文件的文件。

HKEY_CURRENT_USER \Software \ Mycoftoft \ Windows \Curre ntVersion\Explorer \FileExts\.pdf \ OpenWithList

HKEY_CURRENT_USER \Software \ Microsoft \ Windows \Curre ntVersion \Explorer \FileExts\.pdf \ OpenWithProgids


然后你可以处理用户没有安装.pdf阅读器的情况,将它们引导到FoxIt的网站或其他.pdf阅读器网站。


2.您可以将exe文件的名称作为String变量传递。例如从你的String [] args中获取它。
1. Use the registry class to determine what file is used to open a .pdf file.
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\FileExts\.pdf\OpenWithList
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\FileExts\.pdf\OpenWithProgids

You could then handle the case where the user does not have .pdf reader installed, by directing them to FoxIt''s website, or some other .pdf reader site.

2.You could pass the name of the exe file in as a String variable. eg get it from your String[] args.


谢谢。你能否请你的第一个解决方案......以及任何其他解决方案。
Thanks. Could you please brief your first solution.. And any other solutions.


java.awt.Desktop有一个 open()方法。
java.awt.Desktop has an open() method.