参考:http://suvk.blog.sohu.com/159274256.html
先把想要在线阅读的文档转换成swf格式,再用flash读取转换后的swf文件即可实现在线阅读功能。
播放器及组件下载地址:
http://code.google.com/p/flexpaper/downloads/list
下载JODConverter:
http://sourceforge.net/projects/jodconverter/files/
利用jodconverter将doc转成pdf的例子:
将jodconverter的lib下的jar加入到classpath。
FileConverter.java代码:
import java.io.File;import java.net.ConnectException;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
public class FileConverter {
/*** @param args*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// 1.doc转成pdf
File docInputFile = new File("F:\\PowerDesigner\\PowerDesigner建模实例\\课件\\PD和rose比较.doc");
File pdfOutputFile = new File("F:\\PowerDesigner\\PowerDesigner建模实例\\课件\\PD和rose比较.pdf");
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
} catch (ConnectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(docInputFile, pdfOutputFile);connection.disconnect();
}
}
说明:这个转换需要安装有openoffice。下载swftools,将pdf转成swf。
http://www.oschina.net/p/swftools
最后利用flexplayer播放器就可以了。