今天转了一个的pdf是出现字符集问题,并转换的swf为乱码。
出现的错误如下。
错误的原因是缺少中文字符集GBK-EUC-H。解决方法使用xpdf增加缺少的字符集。解决步骤如下:
(一) 下载相关的xpdf及字符集
xpdf-3.02pl5-win32.zip
下载地址为
ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.02pl5-win32.zip
xpdf-chinese-simplified.tar.gz
下载地址为
ftp://ftp.foolabs.com/pub/xpdf/xpdf-chinese-simplified.tar.gz
也可以去http://www.foolabs.com/xpdf/download.html查找你自己需要的字符集
以上两个文件我已经放到附件里面有用的话可以下载
(二) 配置xpdf及字符集
1:解压xpdf-3.02pl5-win32.zip,解压后修改名称为xpdf,并将其考到c盘根目录下【路径可以随意指定,但是执行pdf2swf指令时要指定到当前目录】。
2:解压xpdf-chinese-simplified,将xpdf-chinese-simplified放置xpf目录下
3:修改xpdf-chinese-simplified目录下的add-to-xpdfrc文件
- #----- begin Chinese Simplified support package (2004-jul-27)
- cidToUnicode Adobe-GB1 c:xpdfxpdf-chinese-simplifiedAdobe-GB1.cidToUnicode
- unicodeMap ISO-2022-CN c:xpdfxpdf-chinese-simplifiedISO-2022-CN.unicodeMap
- unicodeMap EUC-CN c:xpdfxpdf-chinese-simplifiedEUC-CN.unicodeMap
- unicodeMap GBK c:xpdfxpdf-chinese-simplifiedGBK.unicodeMap
- cMapDir Adobe-GB1 c:xpdfxpdf-chinese-simplifiedCMap
- toUnicodeDir c:xpdfxpdf-chinese-simplifiedCMap
- fontDir C:WINDOWSFonts
- displayCIDFontTT Adobe-GB1 C:WINDOWSFontssimhei.ttf
- #displayCIDFontTT Adobe-GB1 /usr/..../gkai00mp.ttf
- #----- end Chinese Simplified support package
#----- begin Chinese Simplified support package (2004-jul-27) cidToUnicode Adobe-GB1 c:xpdfxpdf-chinese-simplifiedAdobe-GB1.cidToUnicode unicodeMap ISO-2022-CN c:xpdfxpdf-chinese-simplifiedISO-2022-CN.unicodeMap unicodeMap EUC-CN c:xpdfxpdf-chinese-simplifiedEUC-CN.unicodeMap unicodeMap GBK c:xpdfxpdf-chinese-simplifiedGBK.unicodeMap cMapDir Adobe-GB1 c:xpdfxpdf-chinese-simplifiedCMap toUnicodeDir c:xpdfxpdf-chinese-simplifiedCMap fontDir C:WINDOWSFonts displayCIDFontTT Adobe-GB1 C:WINDOWSFontssimhei.ttf #displayCIDFontTT Adobe-GB1 /usr/..../gkai00mp.ttf #----- end Chinese Simplified support package
(三) 执行pdf2swf命令时增加字符集指令
php代码修改为
- $command= "D:/SWFTools/pdf2swf.exe -t "".$dir."\test.pdf" -o "".$dir."\test.swf" -s flashversion=9 -s languagedir=\xpdf\xpdf-chinese-simplified";
$command= "D:/SWFTools/pdf2swf.exe -t "".$dir."\test.pdf" -o "".$dir."\test.swf" -s flashversion=9 -s languagedir=\xpdf\xpdf-chinese-simplified";
java代码修改为
- String command= "D:/SWFTools/pdf2swf.exe -t ""+path+"\test.pdf" -o ""+path+"\test.swf" -s flashversion=9 -s languagedir=C:\xpdf\xpdf-chinese-simplified ";
String command= "D:/SWFTools/pdf2swf.exe -t ""+path+"\test.pdf" -o ""+path+"\test.swf" -s flashversion=9 -s languagedir=C:\xpdf\xpdf-chinese-simplified ";
- String command= "D:/SWFTools/pdf2swf.exe -t ""+path+"\test.pdf" -o ""+path+"\test.swf" -s flashversion=9 -s languagedir=C:\xpdf\xpdf-chinese-simplified ";
String command= "D:/SWFTools/pdf2swf.exe -t ""+path+"\test.pdf" -o ""+path+"\test.swf" -s flashversion=9 -s languagedir=C:\xpdf\xpdf-chinese-simplified ";
以上完成关于字符集乱码的配置。
增加完成后执行命令可以看到adding命令
以上不能全部解决字符集乱码的问题可能还会缺少字符
可以看缺少什么字符集就加什么字符集
- displayCIDFontTT Adobe-GB1 C:WINDOWSFonts你的字符集
附件xpf.rar为我的配置可以参考
- xpdf-chinese-simplified.tar.gz (816.4 KB)
- xpdf-3.02pl5-win32.zip (2 MB)
- xpdf.rar (2.3 MB)
在此感谢原作分享