[英]How to preview any files inside a Java application?
I'm using a JTree to browse the content of a folder and I want that when a user click on a file, the software shows a preview of it (a screenshot of its first page). 我正在使用JTree浏览文件夹的内容,我希望当用户单击文件时,该软件可以显示该文件的预览(其第一页的屏幕截图)。
The files are mostly Office documents and PDF. 这些文件主要是Office文档和PDF。
I manage to do it for PDF file using a module downloaded from Sun, but I'd like to know if there is a way to do it using any software (JARs preferably) or even the built-in Windows API. 我设法使用从Sun下载的模块来处理PDF文件,但是我想知道是否可以使用任何软件(最好是JAR)甚至内置Windows API来处理。
I was thinking of converting the file to PDF then do a preview of this PDF but this isn't optimal. 我当时想将文件转换为PDF,然后预览此PDF,但这并不是最佳选择。
Any ideas ? 有任何想法吗 ?
I've got the similar problem and the best I found after couple of days of googling is following. 我遇到了类似的问题,经过几天的谷歌搜索后发现的最好结果是。
Alfresco has the same problem and resolved it with : Alfresco也有同样的问题,并使用以下方法解决了:
Personnaly, I will try to implement it this way : 从个性上讲,我将尝试通过以下方式实现它:
I had the same problem too and stumbled over this thread. 我也有同样的问题,偶然发现了这个线程。 Starting with the solution from Anthony I am using Libre Office in socket mode to convert office documents directly to a PNG. 从Anthony的解决方案开始,我正在以套接字模式使用Libre Office将Office文档直接转换为PNG。 Unfortunately this isn't posible from PDF's. 不幸的是,这是不可能的。 Here is a good overview which ways are possible. 这是一个很好的概述,列出了可行的方法。
unoconv --connection 'socket,host=127.0.0.1,port=2220,tcpNoDelay=1;urp;StarOffice.ComponentContext' -f png -e PageRange=1 your_file_name.extension
Little reference to start Libre Office in socket mode: click me 在套接字模式下启动Libre Office的小参考: 单击我
我很久以前问过这个: 解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.