Original Blog http://blog.csdn.net/zfw198787/article/details/48781357
Most detailed online preview of the file (openoffice+swftools+flexpaper) 1.1 I use the latest software packages, the version is shown in the following figure:
1.2 Loading Chinese file name is supported 1.3 Code Download
1. Overview
Main principles
1. Convert Word, Excel, PPT, TXT and other files to PDF files via third-party tool OpenOffice
2. Convert PDF files to SWF-formatted files via Swftools
3. Display on the page via the Flexpaper document component
2. installation package Download
1.openoffice is an open, free word processing software under Apache.
Download version: 4.1.0
Download Address: http://www.openoffice.org/zh-cn/download/
2.SWFTools is a set of toolkit for working with Flash SWF files, which we use to convert PDF files to swf files!
Download version: swftools-2013-04-09-1007
Download Address: http://www.swftools.org/download.html
3.FlexPaper is an open source lightweight component that displays various documents on a browser
Download Address: Flexpaper official website download
4.JODConverter A Java OpenDocument file converter, where we only use its jar package
Download Address: Jodcconverter download
3. installation files
1. Install the downloaded file (except Jodconverter), and set the disk used by itself with your own. Note that after the OpenOffice installation is complete, when we use it, we need to open its service. At times we need to open it as a command:
Open the DOS window, enter the OpenOffice installation letter, enter the following code to start the service:
Soffice-headless-accept= "SOCKET,HOST=127.0.0.1,PORT=8100;URP;" -nofirststartwizard
Pay attention to the '-' in front of the last command, but don't write it wrong. Service does not come, the project but continue to not go on OH.
The official website launches the service screenshot as follows:
Local screenshot:
3. Development process
1. Create a new project, the JS folder in the Flexpaper file (contains Flexpaper_handlers.js,flexpaper.js, Jquery.extensions.min.js,jquery.min.js, Three.min.js These five JS files are mainly preview SWF file plugin) copy to the Web site root directory of the JS folder, the locale folder to the root directory, the CSS folder to copy to the root directory, Copy the flexpaperviewer.swf to the root of the Web site (the file is primarily used to play the SWF file in a Web page), the directory structure is as follows:
Note: The jar package goes to the downloaded file in the Lib directory to find. The path to the pdf2swf command in the Docconverter class method pdf2swf () is configured according to the actual value.
2. Create fileupload.jsp
<%@ pagelanguage= "java" contenttype= "Text/html;charset=utf-8" pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtdhtml 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Document Online Preview system </title>
<style>
Body {margin-top:100px;background: #fff; Font-family:verdana, Tahoma;}
A {color: #CE4614;}
#msg-box {color: #CE4614; font-size:0.9em;text-align:center;}
#msg-box. Logo {border-bottom:5px solid #ECE5D9; margin-bottom:20px;padding-bottom:10px;}
#msg-box. title {font-size:1.4em;font-weight:bold;margin:0 0 30px 0;}
#msg-box. Nav {margin-top:20px;}
</style>
<body>
<div id= "Msg-box" >
<form name= "Form1" method= "Post" enctype= "Multipart/form-data" action= "docuploadconvertaction.jsp" >
<div class= "title" >
Please upload the file to be processed, the process may take a few minutes, please wait a moment.
</div>