All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lone.common.core.swftools.SWFToolsSWFConverter Maven / Gradle / Ivy

The newest version!
package com.lone.common.core.swftools;

import java.io.File;
import java.io.IOException;

import com.lone.common.util.FileUtils;
import com.lone.common.util.PinyinUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class SWFToolsSWFConverter implements SWFConverter {
	/** SWFTools pdf2swf.exe路径 */
	private static String PDF2SWF_PATH = ConStant.SWFTOOLS_PDF2SWF_PATH;

	public void convert2SWF(String inputFile, String swfFile, String extend) {
		File pdfFile = new File(inputFile);
		File outFile = new File(swfFile);
		
		if (!pdfFile.exists()) {
			log.info("PDF文件不存在!");
			return;
		}
	
		if (outFile.exists()) {
			log.info("SWF文件已存在!");
			return;
		}
		String command = ConStant.getSWFToolsPath(extend) + " \"" + inputFile

				+ "\" -o " +" \""+ swfFile +" \""+ " -s languagedir=D:\\xpdf-chinese-simplified -T 9 -f";
//				+ "\" -o " + swfFile + " -s languagedir=D:\\xpdf-chinese-simplified -T 9 -f";
		try {
			// 开始转换文档
			Process process = Runtime.getRuntime().exec(command);
			StreamGobbler errorGobbler = new StreamGobbler(
					process.getErrorStream(), "Error");
			StreamGobbler outputGobbler = new StreamGobbler(
					process.getInputStream(), "Output");
			errorGobbler.start();
			outputGobbler.start();
			try {
				process.waitFor();
				log.info("时间-------"+process.waitFor());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void convert2SWF(String inputFile, String extend) {
		String swfFile = PinyinUtil.getPinYinHeadChar(FileUtils.getFilePrefix2(inputFile)) + ".swf";
		convert2SWF(inputFile, swfFile, extend);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy