使用SWFTools将pdf转成swf

1.下载swfTools并安装,下载地址http://www.swftools.org/download.html

2.复制代码到工具类中

 1 ...
 2     
 3     /**
 4      * pdf转swf
 5      * swfDir 存的exe文件路径,我的是:D:/SWFTools/pdf2swf.exe
 6      *
 7      */
 8     private File pdf2swf(File pdfFile) throws Exception {
 9         //下载的文件转成pdf的pdf将要放置的路径
10         String swfPath = templateSwfDir + pdfFile.getName() + ".swf";
11         File swfFile = new File(swfPath);
12         Runtime r = Runtime.getRuntime();
13         if (swfFile.exists()) {
14             swfFile.delete();
15         }
16         if (!pdfFile.exists()) {
17             throw new Exception("程序出现问题,pdf不存在");
18         }
19         try {
20             Process p = r.exec(swfDir + " " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
21             loadStream(p.getInputStream());
22             loadStream(p.getErrorStream());
23             loadStream(p.getInputStream());
24         } catch (IOException e) {
25             e.printStackTrace();
26             throw e;
27         }
28         return swfFile;
29     }
30 
31     static String loadStream(InputStream in) throws IOException {
32         int ptr = 0;
33         in = new BufferedInputStream(in);
34         StringBuffer buffer = new StringBuffer();
35         while ((ptr = in.read()) != -1) {
36             buffer.append((char) ptr);
37         }
38         return buffer.toString();
39     }
40 ...

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值