doc转swf

将doc转换成swf,然后显示在html页面上。

package org.forever.util;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

public class FlashPaperUtil {
	private static final String UNINSTALL_BAT = "uninstall.bat";
	private static final String INSTALL_BAT = "install.bat";
	private static Logger log = Logger.getLogger(FlashPaperUtil.class);
	private static final String CMD_C_START = "cmd /c start ";
	private static final String FLASH_PRINTER_EXE = "FlashPrinter.exe";
	private static final String FLASH_PAPER2_2 = "FlashPaper2.2";
	private static final String SPACE = " ";
	private static String flashPaperDir;
	private static String flashPrinterPath;
	private static String installPath;
	private static String unInstallPath;
	private static Runtime runtime = Runtime.getRuntime();
	
	private static Map<String, String> fileMap = new HashMap<String, String>();
	private static FlashPaperUtil instance;
	
	
	private FlashPaperUtil(){
		flashPaperDir = 
			FlashPaperUtil.class.getClassLoader().getResource(
					FLASH_PAPER2_2).getFile();
		for (File file : new File(flashPaperDir).listFiles()) {
			fileMap.put(file.getName(), file.getAbsolutePath());
		}
		flashPrinterPath = fileMap.get(FLASH_PRINTER_EXE);
		installPath = fileMap.get(INSTALL_BAT);
		unInstallPath = fileMap.get(UNINSTALL_BAT);
	}
	
	public static FlashPaperUtil getInstance(){
		if(null == instance){
			synchronized (FlashPaperUtil.class) {
				instance = new FlashPaperUtil();
			}
		}
		return instance;
	}

	public void docToSwf(String docPath, String outPath)
			throws Exception {
		String command = flashPrinterPath + SPACE + docPath + SPACE + "-o"
				+ SPACE + outPath;
		Process process = runtime.exec(command);
		process.waitFor();
		process.destroy();
		File outFile = new File(outPath);
		if(outFile.exists()){
			log.info("docToSwf success.........");
		}
	}

	public void install() throws Exception {
		String cmd = CMD_C_START + installPath;
		Process process = runtime.exec(cmd,null,new File(flashPaperDir));
		process.waitFor();
		process.destroy();
		log.info("install success..........");
	}

	public void uninstall() throws Exception {
		String cmd = CMD_C_START + unInstallPath;
		Process process = runtime.exec(cmd,null,new File(flashPaperDir));
		process.waitFor();
		process.destroy();
		log.info("uninstall success..........");
	}

	public static void main(String[] args) throws Exception {
		FlashPaperUtil.getInstance();
	}

}

 

 该工具不适用于64



 如果要用64的,使用print2Flash,掉用命令:

p2Server.exe F:\abc.doc F:\abc.swf /createlogfile:on /logfilename:F:\doc2swf.log

或者p2Server.exe F:\abc.doc F:\abc.swf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值