You are on page 1of 10

*.

*-pdf -swf

1. Txt/Word/Excel/PPT=>PDF(OpenOffice+JodConverter)=>SWF(pdf2swf)=>FlexPap er 2. Txt/Word/Excel/PPT=>PDF(MSOffice+JACOB)=>SWF(pdf2swf)=>FlexPaper 3. Txt/Word/Excel/PPT=>SWF (FlashPaper)=> FlexPaper 4. Txt/Word/Excel/PPT=>SWF(print2flash)=> FlexPaper 1,2 PDF SWF 2 flashpaper 30 print2flash swf Java 2

OpenOffice JodConverter Swftools(pdf2 swf) FlexPaper http://zh.openoffice.org/new/zh_cn/downloads.html http://dldx.csdn.net/fd.php?i=992314146801277&s=08dbee 95a6e2dda1a95aa8cbf4df197b http://dldx.csdn.net/fd.php?i=389133735472350&s=2f7430 ad3c00cca78ada8b4671a50b24 http://flexpaper.googlecode.com/files/FlexPaper_1.4.5_ flash.zip

lib JodConverter lib jar

ConvertServlet servlet package org.gfg.test.servlet; import java.io.File; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.artofsolving.jodconverter.DocumentConverter; import com.artofsolving.jodconverter.openoffice.connection.OpenO fficeConnection; import com.artofsolving.jodconverter.openoffice.connection.Socke tOpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.converter.OpenOf ficeDocumentConverter;

public class ConvertServlet extends HttpServlet { private File sourceFile; private File pdfFile; private File swfFile; private Runtime r; public void init() throws ServletException { sourceFile = new File("G:\\tomcat6\\webapps\\readonline\\swfFile\\1.doc"); pdfFile = new File("G:\\tomcat6\\webapps\\readonline\\swfFile\\1.pdf"); swfFile = new File("G:\\tomcat6\\webapps\\readonline\\swfFile\\Paper.sw f"); System.out.println(""); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred // //PDF //SWF

* @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); //pdf if(sourceFile.exists()) { if(!pdfFile.exists()) { OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100); try { connection.connect(); DocumentConverter converter = new OpenOfficeDocumentConverter(connection); converter.convert(sourceFile, pdfFile); pdfFile.createNewFile(); connection.disconnect(); System.out.println("PDF " + pdfFile.getPath()); } catch (java.net.ConnectException e) { e.printStackTrace(); System.out.println("OpenOffice"); throw e; } catch (com.artofsolving.jodconverter.openoffice.connection.Open OfficeException e) { e.printStackTrace(); System.out.println(""); throw e; } catch (Exception e){ e.printStackTrace(); try { throw e;

} catch (Exception e1) { e1.printStackTrace(); } } } else { System.out.println("PDF"); } } else { System.out.println(""); } //swf r = Runtime.getRuntime(); new Thread(){ @Override public void run() { if(!swfFile.exists()){ if(pdfFile.exists()) { try { System.out.println("E:/SWFTools/pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9"); Process p = r.exec("E:/SWFTools/pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9"); p.waitFor(); swfFile.createNewFile(); System.out.println(" SWF " + swfFile.getPath());

System.out.println("siSWF mingcheng" + swfFile.getName()); // // // } } catch (Exception e) { e.printStackTrace(); try { throw e; } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } else { System.out.println("PDF "); } } else { System.out.println("SWF "); } } }.start(); HttpSession session = request.getSession(); session.setAttribute("fileName", swfFile.getName()); System.out.println(" :"+session.getAttribute("fileName")); response.sendRedirect(request.getContextPath()+"/readF ile.jsp"); } if(pdfFile.exists()) { pdfFile.delete();

Readfile.Jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+req uest.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title></title> <style type="text/css" media="screen"> html, body { height:100%; } body { margin:0; padding:0; overflow:auto; } #flashContent { display:none; } </style> <script type="text/javascript" src="flexpaper/js/flexpaper_flash_debug.js"></script> <script type="text/javascript" src="flexpaper/js/jquery.js"></script> <script type="text/javascript" src="flexpaper/js/flexpaper_flash.js"></script> </head>

<body> <div style="position:absolute;left:200px;top:10px;"> <center> <a id="viewerPlaceHolder" style="width:1000px;height:800px;display:block"> ............</a></center> <script type="text/javascript"> $(document).ready(function(){ var fp = new FlexPaperViewer( 'flexpaper/FlexPaperViewer', 'viewerPlaceHolder', { config : { SwfFile : escape('http:\/\/192.168.0.13:8080\/readonline\/swfFile\/ <%=request.getAttribute("fileName")%>'), Scale : 0.6, ZoomTransition : 'easeOut', ZoomTime : 0.5, ZoomInterval : 0.2, FitPageOnLoad : true, FitWidthOnLoad : false, PrintEnabled : true, FullScreenAsMaxWindow : false, ProgressiveLoading : true, MinZoomSize : 0.2, MaxZoomSize : 5, SearchMatchAll : false, InitViewMode : 'Portrait', ViewModeToolsVisible : true, ZoomToolsVisible : true, NavToolsVisible : true, CursorToolsVisible : true, SearchToolsVisible : true,

localeChain: 'zh_CN' }}); }); </script> </div> </body> </html>

FlexPaperViewer id Paper.swf SwfFile

swf adobe servlet

You might also like