PDF转化成swf

import java.io.BufferedReader;
import java.io.File;   
import java.io.IOException;  
import java.io.InputStreamReader;
import java.net.MalformedURLException; 
import com.itextpdf.text.*;   

/**
 * 讲pdf转化成swf
 */
public class CopyOfLook {
  //SWFTools的环境安装路径  
   public static String SWFTOOLS_PATH="D:"+File.separator+"Program Files"+File.separator+"SWFTools"+File.separator;  

   //播放器样式文件rfxview.swf的路径  
   public static String RFXVIEW_SWF_PATH="D:"+File.separator+"rfxview.swf";  
   
	public static int pdf2SWF(String sourceFile, String destFile) {  
  
        // 目标路径不存在则建立目标路径  
        File dest = new File(destFile);  
        if (!dest.getParentFile().exists()) { 
            dest.getParentFile().mkdirs();  
        }
  
        // 源文件不存在则返回 -1  
        File source = new File(sourceFile);  
        if (!source.exists()) {
        	 return -1; 
        }  
        String SWFTools_HOME = "D:\\Program Files\\SWFTools";
         
        try {  
            // 调用pdf2swf命令进行转换swfextract -i - sourceFilePath.pdf -o destFilePath.swf //注意linux下的书写    \\pdf2swf.exe
            String command =  SWFTools_HOME + "\\pdf2swf.exe  -i " + sourceFile + " -o "  
                    + destFile;  
            Process pro = Runtime.getRuntime().exec(command);  
  
            BufferedReader bufferedReader = new BufferedReader(  
                    new InputStreamReader(pro.getInputStream()));  
            while (bufferedReader.readLine() != null) {  
  
            }  
            pro.waitFor(); 
             
         // 然后在套播放器       ----
            String  command1 = "cmd /c \""+SWFTOOLS_PATH+"swfcombine\" "+RFXVIEW_SWF_PATH+" viewport=" + destFile + " -o " + destFile;       

      		Process   pro1 = Runtime.getRuntime().exec(command1);       

      		BufferedReader  bufferedReader1 = new BufferedReader(new InputStreamReader(pro1.getInputStream()));       
      		 while (bufferedReader1.readLine() != null) {       

     	       }  
    	       try {       

    	           pro1.waitFor();       

    	       } catch (InterruptedException e) {       

    	           e.printStackTrace();       

    	       }  
        
            return pro.exitValue();  
        } catch (InterruptedException e) {  
            e.printStackTrace();  
        } catch (IOException e1) {  
            e1.printStackTrace();  
        }  
 
        return 1;  
     }
	
	public static void main(String[] str) throws MalformedURLException, IOException, DocumentException{
		 
		
		String ywj="D:\\pdf.pdf";
		String mbwj="D:\\11.swf";
		
		pdf2SWF(ywj,mbwj );
	 
	}
}

















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值