java中调用swftools软件将pdf转化为swf文件 在线预览之步骤二

在电脑中安装swftools软件

例如:

我的安装路径:E:\\安装软件\\swftools\\pdf2swf.exe

转化工具类:

package cn;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
/**
 * 将pdf转化为swf文件
 * @author 
 *
 */
public class Converter {  
	private static String pdftoswf = "E:\\安装软件\\swftools\\pdf2swf.exe";
	/** 
	 * @param sourcePath  pdf原路径
	 * @param destPath    目的路径
	 * @param fileName    生成swf的文件名
	 */
    public static int convertPDF2SWF(String sourcePath, String destPath, String fileName) throws Exception {  
        //目标路径不存在则建立目标路径  
        File dest = new File(destPath);  
        if (!dest.exists()) dest.mkdirs();  
          
        //源文件不存在则返回  
        File source = new File(sourcePath);  
        if (!source.exists()) return 0;  
          
        //调用pdf2swf命令进行转换  
        String command = pdftoswf + " -o \"" + destPath + "\\" + fileName + "\"  -s flashversion=9 \"" + sourcePath + "\"";  
          
        Process pro = Runtime.getRuntime().exec(command);  
          
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pro.getInputStream()));  
        while (bufferedReader.readLine() != null);   
          
        try {  
            pro.waitFor();  
        } catch (InterruptedException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }  
          
        return pro.exitValue();  
          
    }  
      
    public static void main(String []args) throws Exception {  
        String sourcePath = "C:\\Users\\Administrator\\Desktop\\1\\1.pdf";  
        String destPath = "C:\\Users\\Administrator\\Desktop\\1\\";  
        String fileName = "test.swf";  
        Converter.convertPDF2SWF(sourcePath, destPath, fileName);  
    }  
}  


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值