1. 下载swftools
2. 安装环境
[root@centos]# yum -y install gcc* automake giflib-devel libjpeg-devel freetype-devel t1lib-devel zlib
3. 安装swftools
[root@centos]# tar -xzvf swftools-0.9.2.tar.gz
[root@centos]# cd swftools-0.9.2
#--prefix 是指定的安装路径
[root@centos]# ./configure --prefix=/usr/local/swfTools
[root@centos]# make
[root@centos]# make install
这个过程如果出现报错:
类似于
make[1]: *** [install] 报错信息
make[1]: Leaving directory `/root/swftools-0.9.2/swfs'
make: *** [install] 报错信息
解决的办法是修改swftools-0.9.2/swfs下的Makefile和Makefile.in文件;
install:
$(mkinstalldirs) $(pkgdatadir)
$(mkinstalldirs) $(pkgdatadir)/swfs
$(INSTALL_DATA) ./simple_viewer.swf $(pkgdatadir)/swfs/simple_viewer.swf
$(INSTALL_DATA) ./keyboard_viewer.swf $(pkgdatadir)/swfs/keyboard_viewer.swf
$(INSTALL_DATA) ./PreLoaderTemplate.swf $(pkgdatadir)/swfs/PreLoaderTemplate.swf
$(INSTALL_DATA) ./tessel_loader.swf $(pkgdatadir)/swfs/tessel_loader.swf
$(INSTALL_DATA) ./swft_loader.swf $(pkgdatadir)/swfs/swft_loader.swf
==rm -f $(pkgdatadir)/swfs/default_viewer.swf -o -L $(pkgdatadir)/swfs/default_viewer.swf==
$(LN_S) $(pkgdatadir)/swfs/simple_viewer.swf $(pkgdatadir)/swfs/default_viewer.swf
==rm -f $(pkgdatadir)/swfs/default_loader.swf -o -L $(pkgdatadir)/swfs/default_loader.swf==
$(LN_S) $(pkgdatadir)/swfs/tessel_loader.swf $(pkgdatadir)/swfs/default_loader.swf
将两个文件中的标记的 -o -L 去掉;
然后在make install即可;
4. 安装xpdf(解决乱码问题)
下载 xpdf-chinese-simplified.tar.gz
下载gbsn00lp.ttf 和 gkai00mp.ttf
解压对应文件
[root@centos]# tar -zxvf xpdf-chinese-simplified.tar.gz
[root@centos]# mv xpdf-chinese-simplified /usr/local
# 将字体文件复制到对应文件夹下,防止乱码
[root@centos]# mv Gbsn00lp.ttf gkai00mp.ttf /usr/local/xpdf-chinese-simplified/CMap/
5. 设置swftools环境变量,使pdf2swf成为一个可执行命令
[root@centos]# vim /etc/profile
export PATH=$PATH:/usr/local/swfTools/bin/
6. 测试
[root@centos]# pdf2swf -s languagedir=/usr/local/xpdf-chinese-simplified -T 9 -s poly2bitmap -s zoom=150 -s flashversion=9 "/opt/123.pdf" -o "/opt/test/%.swf"
7. 常见问题
- 问题1:
modules/.././types.h:39:2: 错误:#error "no way to define 64 bit integer" modules/.././types.h:42:2: 错误:#error "don't know how to define 32 bit integer" modules/.././types.h:45:2: 错误:#error "don't know how to define 16 bit integer" modules/.././types.h:48:2: 错误:#error "don't know how to define 8 bit integer" # 解决方法: [root@centos]# ldconfig /usr/local/lib [root@centos]# ldconfig /usr/local/lib [root@centos]# ./configure
- 问题2:
rm -f /usr/local/swfTools/share/swftools/swfs/default_viewer.swf -o -L /usr/local/swfTools/share/swftools/swfs/default_viewer.swf rm:无效选项 -- o Try 'rm --help' for more information. make[1]: *** [install] 错误 1 make[1]: 离开目录“/opt/swftools-0.9.2/swfs” make: *** [install] 错误 2 # 解决方法: [root@centos]# find ./ |xargs grep -r -i "default_viewer" #筛选出对应的问题文件其实即swfs目录下的Makefile和Makefile.in两个文件,讲两个文件中的有 -o -L的地方去掉即可
- 问题3:
make[1]: Entering directory `/opt/swftools-0.9.2/swfs' /bin/sh ../mkinstalldirs /usr/local/swfTools/share/swftools /bin/sh ../mkinstalldirs /usr/local/swfTools/share/swftools/swfs /usr/bin/install -c -m 644 ./simple_viewer.swf /usr/local/swfTools/share/swftools/swfs/simple_viewer.swf /usr/bin/install: cannot stat ‘./simple_viewer.swf’: No such file or directory make[1]: *** [install] Error 1 make[1]: Leaving directory `/opt/swftools-0.9.2/swfs' make: *** [install] Error 2 # 解决方法:重新下载安装包,这里的安装包对应文件夹找不到对应的simple_viewer.swf文件