PDFをSWFに変換するために使用するPdf2swf



Pdf2swf Use Convert Pdf Swf



コードをPDFSWFに変換することにより、現在より一般的に使用されている方法は、SWFToolsツールpdf2swf( http://www.swftools.org/ )。このツールは非常に使いやすいです。 SWFファイルの変換品質も良好です。

* PDF tool turn SWF * @author tangs * */ public class Converter { public static int convertPDF2SWF(String sourcePath, String destPath, String fileName) throws IOException { // target path does not exist, create the target path File dest = new File(destPath) if (!dest.exists()) dest.mkdirs() // Returns the source file does not exist File source = new File(sourcePath) if (!source.exists()) return 0 // Call command to convert pdf2swf String command = 'D:\Program Files\SWFTools\pdf2swf.exe' + ' -o '' + destPath + '\' + fileName + '' -s languagedir=D:\xpdf\xpdf-chinese-simplified -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 IOException { String sourcePath = 'c:\test.pdf' String destPath = 'c:\' String fileName = 'test.swf' Converter.convertPDF2SWF(sourcePath, destPath, fileName) } }

それはその単純な数行のコードです。しかし、プログラムでの中国の経験は予期しない状況になるでしょう、これは例外ではありません。変換では、中国語のPDFファイル変換後に文字化け現象が発生したため、ここでゴミの問題に対処する必要があります。赤いピリオドの上のコードはまだ表示されていますか?これがゴミを解決する方法です。この方法は参考です http://hi.baidu.com/xwx520/blog/item/1d0c423885b392fab311c72e.html この記事、作者に感謝します。



1. XPDFをダウンロードします:ftp://ftp.foolabs.com/pub/xpdf/xpdf-chinese-simplified.tar.gz、xpdf-chinese-simplifiedディレクトリに抽出します。

2.フォントのダウンロード: http://blog.pjoke.com/wp-content/uploads/2009/02/font.zip 、およびxpdf-中国語-簡体字/ CMapディレクトリへの抽出。



3.xpdf-chinese-simplifiedディレクトリのadd-to-xpdfrcファイルを変更します。パスの内側は独自のパスを設定します。

4.上記のコードを参照すると、呼び出しpdf2swf 'に追加されたコマンド-s languagedir = D:\ xpdf \ xpdf-chinese-simplified 'パラメーター。



だから文字化けした問題は解決されました。