Mac compilation Installation Swftools
- Mac compilation Installation Swftools
- Download source code
- Decompression source
- Install dependencies
./configure
Perform the configuration or perform the following configuration commands:
- It is important to note that there are some code errors that need to be corrected and executed
- One, char * and int comparison caused by error, need to fix file
- There are some errors that are not defined by the variables
- Third, there are some methods parameter number error and some functions do not define the problem
make
Compile
make install
Installation
- Develop note points
- About the pdf2swf transcoding command:
- Java code calls to execute the document conversion code:
Download source code
Here to download the installation is swftools-0.9.2.tar.gz
, the specific address is:http://www.swftools.org/swftools-0.9.2.tar.gz
Swftools-0.9.2.ta
Unzip the source installation dependencies
# Linux/CentOS 安装 这里没有实际测试,需要自己去测试 这里只是一个记录yum install gcc* automake zlib-devel libjpeg-devel giflib-devel freetype-devel
Install four packages mainly through brew: Lzlib, Giflib, JPEG, FreeType
Mac Version installation command:
# 注意 lzlib 也许是不需要安装的,这里没有去测试brew install lzlibbrew install giflibbrew install jpegbrew freetype
./configure
Perform the configuration or perform the following configuration commands:
sudo LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local/swftools
Note that there are some code errors here, need to modify the solution after the execution of a, char * and int comparison caused by the error, need to fix the file
Error message:
?
swftools-0.9.2/lib/pdf/xpdf/GlobalParams.cc
Modify in File
1 Inserting a file header
#include <stdlib.h>
2 Error handling code
(The specific modification location can refer to the error prompt), the original code is directly using variables to do the comparison, here need to call the function of the variable atio
after comparison
?
There are some errors that are not defined by the variables
Error message:
?
There swftools-0.9.2/lib/jpeg.c
are some variables in the file that are not defined and need to be modified
?
Modified code:
//修改后代码#ifdef HAVE_JPEGLIB#ifndef FALSE #define FALSE 0 #endif#ifndef TRUE#define TRUE 1#endif#define HAVE_BOOLEAN#include <jpeglib.h>
Third, there are some methods parameter number error and some functions do not define the problem
Error message:
?
Solution:
Modify files swftools-0.9.2/src/gif2swf.c
and other content:
1.1 Global Search DGifOpenFileName
and DGifCloseFile
invocation
1.2 Define variables where there are calls to the above two methods
c
int Error;
And the modified call is:
c
DGifOpenFileName(sname, &Error)
?
Note: It is important to note that if these two methods are called in the same method, you can simply define the variables once
1.3 Search globally in the current file to PrintGifError();
Remove or comment out this line of code.
make
Compile
make install
Installation development note about the pdf2swf transcoding command:
pdf2swf -t "/Users/zhangxiong/project/qware/wbiot/mus/MS-FS-Server/tempFile/5bd8f9d8-185d-4d7b-9be8-1658441f784f.pdf" -o
Note: If the transcoding is performed on the Java command line, the file path and the generated path cannot be enclosed in double quotes, which means that the file source and destination paths cannot have spaces
Java code calls to execute the document conversion code:
Note: If the transcoding is performed on the Java command line, the file path and the generated path cannot be enclosed in double quotes, which means that the file source and destination paths cannot have spaces
Package Cn;import java.io.*;/** * Convert PDF to SWF file * requires tool swftools-pdf2swf * * @author * */public class Pdf2swfutil { pdf2swf execute file path private static String pdftoswf = "devtools/swftools-0.9.2/src/pdf2swf"; /** * @param sourcepath PDF Original Path * @param destpath destination path * @param filename generates the file name of the SWF */public STA Tic int convertpdf2swf (string sourcepath, String destpath, String fileName) throws Exception {//target path does not exist then establish target path File Dest = new file (destpath); if (!dest.exists ()) dest.mkdirs (); The source file does not exist and returns file Source = new file (SourcePath); if (!source.exists ()) return 0; Call the pdf2swf command to convert//note here the document input and document output path cannot have spaces, and in this command, the path cannot be wrapped in double quotation marks with String command = pdftoswf + "-o" + dest Path + FileName + "-s flashversion=9" + SourcePath + ""; SYSTEM.OUT.PRINTLN (command); Process Pro = Runtime.getruntime (). exec (command); Final InputStream is1 = Pro.getinPutstream (); New Thread (New Runnable () {public void run () {BufferedReader br = new BufferedReader ( New InputStreamReader (IS1)); StringBuffer sb = new StringBuffer ("====================>>> \ n"); try {String line = null; while (line = Br.readline ())! = null) {sb.append (line); } sb.append ("<<<<<<<========================================"); System.out.println (Sb.tostring ()); } catch (IOException e) {e.printstacktrace (); }}). Start (); Start a separate thread to empty the buffer of Process.getinputstream () final InputStream Is2 = Pro.geterrorstream (); New Thread (New Runnable () {public void run () {BufferedReader br = new BufferedReader ( New INPUTSTREAMREader (IS2)); StringBuffer sb = new StringBuffer ("====================>>> \ n"); try {String line = null; while (line = Br.readline ())! = null) {sb.append (line); } sb.append ("<<<<<<<========================================"); System.out.println (Sb.tostring ()); } catch (IOException e) {e.printstacktrace (); }}). Start (); Starts a separate thread to empty the buffer of the Process.getinputstream () try {pro.waitfor (); } catch (Interruptedexception e) {//TODO auto-generated catch block E.printstacktrace (); } return Pro.exitvalue (); } public static void Main (String []args) throws Exception {//TODO:2018/5/24 Here you need to determine the path and output path of your document String SourcePath = "Downloads/write high-quality code--web the front-end development of the road. pdf "; String destpath = "project/qware/refactor/"; String fileName = "test.swf"; Converter.convertpdf2swf (SourcePath, DestPath, fileName); File File = new file (DestPath + fileName); if (!file.exists ()) {throw new RuntimeException ("not create file"); } } }
Mac compilation Installation Swftools