導航:首頁 > 操作系統 > linux安裝swftools

linux安裝swftools

發布時間:2024-06-28 20:22:55

❶ flexpaper在線預覽問題java linux office文件在線預覽的時候出現如圖的問題,不能預覽,求大神幫忙

swftools-0.9.1.exe 和 FlexPaper_1.4.5_flash.zip,工具網上下載。
二、pdf轉換SWF文件核心類:

public class DocConverter {
private static final int environment = 1;// 環境1:windows,2:linux(涉及pdf2swf路徑問題)
private String fileString;
private String outputPath = "";// 輸入路徑,如果不設置就輸出在默認位置
private String fileName;
private File pdfFile;
private File swfFile;
private File docFile;

public DocConverter(String fileString) {
ini(fileString);
}

/*
* 重新設置 file @param fileString
*/
public void setFile(String fileString) {
ini(fileString);
}

/*
* 初始化 @param fileString
*/
private void ini(String fileString) {
this.fileString = fileString;
fileName = fileString.substring(0, fileString.lastIndexOf("."));
docFile = new File(fileString);
pdfFile = new File(fileName + ".pdf");
swfFile = new File(fileName + ".swf");
}

/*
* 轉為PDF @param file
*/

/*
* 轉換成swf
*/
private void pdf2swf() throws Exception {
Runtime r = Runtime.getRuntime();
if (!swfFile.exists()) {
if (pdfFile.exists()) {
if (environment == 1)// windows環境處理
{
try {
// 這里根據SWFTools安裝路徑需要進行相應更改
Process p = r.exec("G:/Program Files/SWFTools/pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.out.print(loadStream(p.getInputStream()));
System.err.println("****swf轉換成功,文件輸出:" + swfFile.getPath() + "****");
if (pdfFile.exists()) {
// pdfFile.delete();
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} else if (environment == 2)// linux環境處理
{
try {
Process p = r.exec("pdf2swf " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.err.println("****swf轉換成功,文件輸出:" + swfFile.getPath() + "****");
if (pdfFile.exists()) {
pdfFile.delete();
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
} else {
System.out.println("****pdf不存在,無法轉換****");
}
} else {
System.out.println("****swf已存在不需要轉換****");
}
}

static String loadStream(InputStream in) throws IOException {
int ptr = 0;
//把InputStream位元組流 替換為BufferedReader字元流 2013-07-17修改
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder buffer = new StringBuilder();
while ((ptr = reader.read()) != -1) {
buffer.append((char) ptr);
}
return buffer.toString();
}

/*
* 轉換主方法
*/
public boolean conver() {
if (swfFile.exists()) {
System.out.println("****swf轉換器開始工作,該文件已經轉換為swf****");
return true;
}

if (environment == 1) {
System.out.println("****swf轉換器開始工作,當前設置運行環境windows****");
} else {
System.out.println("****swf轉換器開始工作,當前設置運行環境linux****");
}

try {
// doc2pdf();
pdf2swf();
} catch (Exception e) {
// TODO: Auto-generated catch block
e.printStackTrace();
return false;
}

if (swfFile.exists()) {
return true;
} else {
return false;
}
}

/*
* 返迴文件路徑 @param s
*/
public String getswfPath() {
if (swfFile.exists()) {
String tempString = swfFile.getPath();
tempString = tempString.replaceAll("\\\\", "/");
return tempString;
} else {
return "";
}
}

/*
* 設置輸出路徑
*/
public void setOutputPath(String outputPath) {
this.outputPath = outputPath;
if (!outputPath.equals("")) {
String realName = fileName.substring(fileName.lastIndexOf("/"), fileName.lastIndexOf("."));
if (outputPath.charAt(outputPath.length()) == '/') {
swfFile = new File(outputPath + realName + ".swf");
} else {
swfFile = new File(outputPath + realName + ".swf");
}
}
}
}

三、JSP文件,注意引入的幾個js文件和FlexPaperViewer.swf文件,其中FlexPaperViewer.swf和jsp文件放在同一目錄即可。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String paths=(String)request.getAttribute("swfpath");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>te</title>

<style type="text/css" media="screen">
html, body { height:100%; }
body { margin:0; padding:0; overflow:auto; }
#flashContent { display:none; }
</style>

<script type="text/javascript" src="<%=basePath %>js/swfobject/swfobject.js"></script>
<script type="text/javascript" src="<%=basePath %>js/flexpaper_flash.js"></script>
<script type="text/javascript">
//<!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
var swfVersionStr = "10.0.0";
//<!-- To use express install, set to playerProctInstall.swf, otherwise the empty string. -->
/* var xiSwfUrlStr = "playerProctInstall.swf"; */
var xiSwfUrlStr = ""; //值可以任意

var flashvars = {
SwfFile : escape("<%=basePath+paths%>"), //swf文件路徑(lucene4.6和頁面同一個位置)
Scale : 0.6,
ZoomTransition : "easeOut",
ZoomTime : 0.5,
ZoomInterval : 0.1,
FitPageOnLoad : false,
FitWidthOnLoad : true,
PrintEnabled : true,
FullScreenAsMaxWindow : false,
ProgressiveLoading : true,

PrintToolsVisible : true,
ViewModeToolsVisible : true,
ZoomToolsVisible : true,
FullScreenVisible : true,
NavToolsVisible : true,
CursorToolsVisible : true,
SearchToolsVisible : true,

localeChain: "en_US"
};

var params = {

}
params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "FlexPaperViewer";
attributes.name = "FlexPaperViewer";
swfobject.embedSWF(
"FlexPaperViewer.swf", "flashContent",
"1024", "700",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:center;");
</script>

</head>
<body>

<div style="width: 100%;height: 90%; text-align: center;">
<div id="flashContent">
</div>
</div>

</body>
</html>

❷ linux安裝swftools 執行make時報錯

在swftools官網下載最新版本,官網FAQ標簽中給出freetype庫和jpeglib庫的連接,freetype選擇版本freetype-2.1.10.tar.gz,jpeglib選擇版本jpegsrc.v8c.tar.gz。
先安裝gcc、gcc-c++、zlib、zlib-devel

解壓命令: tar -zxvf xxx.tar,解壓下載下來的freetype、jpeglib安裝包
進入安裝包目錄
然後執行:
./configure
make
make install

解壓swftools,進入安裝包目錄,執行以下命令:
ldconfig /usr/local/lib
./configure
make
make install
make clean
make distclean
whereis pdf2swf

運行./configure命令時出現:
checking build system
type... Invalid configuration 'i686-pc-linux-': machine 'i686-pc-linux' not
recognized
configure: error:
/bin/sh ./config.sub i686-pc-linux- failed
就換為執行: ./configure --build=i686-pc-linux-gnu

運行出現:make: Nothing to be done for `unix'.
執行: make clean
然在再執行make即可

如出現創建文件時間問題,調整linux系統時間即可。

❸ linux下用gcc編譯c出現的一些問題,請指教

你做 make 的時候,它會用預先設計好的命令來編譯,連接源代碼.你現在直接 "gcc pdf2swf.c" 就是假定整個程序只有這么一個源文件,沒有非標准庫.估計不大可能.很明顯,源文件至少還有一個 init.c.

既然你已經能做 configure, make 和 make install,不知道為什麼還要 gcc pdf2swf.c?

要用 gdb, make 的時候就必須帶有 debug 信息, g++ 是 -g, gcc 不太清楚, 打 gcc --help 查一下. 另外, make 做完後,源文件不能刪掉/移動,否則 gdb 就找不到了.

------------------

configure 會生成一個 Makefile, 打開後找 CCFLAG (通常是這個變數), 加上 -g 後再做 make 應該可以產生 debug 信息.你可以試試看.

❹ JAVA+JS如何在HTML頁面上顯示WORD文檔內容ActiveX只能兼容IE不考慮!

packagecom.cectsims.util;

importjava.io.BufferedInputStream;
importjava.io.File;
importjava.io.IOException;
importjava.io.InputStream;

importcom.artofsolving.jodconverter.DocumentConverter;
importcom.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
importcom.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
importcom.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;

/**
*docdocx格式轉換
*/
publicclassDocConverter{
=1;//環境1:windows2:linux
privateStringfileString;//(只涉及pdf2swf路徑問題)
privateStringoutputPath="";//輸入路徑,如果不設置就輸出在默認的位置
privateStringfileName;
privateFilepdfFile;
privateFileswfFile;
privateFiledocFile;

publicDocConverter(StringfileString){
ini(fileString);
}

/**
*重新設置file
*
*@paramfileString
*/
publicvoidsetFile(StringfileString){
ini(fileString);
}

/**
*初始化
*
*@paramfileString
*/
privatevoidini(StringfileString){
this.fileString=fileString;
fileName=fileString.substring(0,fileString.lastIndexOf("."));
docFile=newFile(fileString);
pdfFile=newFile(fileName+".pdf");
swfFile=newFile(fileName+".swf");
}

/**
*轉為PDF
*
*@paramfile
*/
privatevoiddoc2pdf()throwsException{
if(docFile.exists()){
if(!pdfFile.exists()){
=newSocketOpenOfficeConnection(8100);
try{
connection.connect();
DocumentConverterconverter=(connection);
converter.convert(docFile,pdfFile);
//closetheconnection
connection.disconnect();
System.out.println("****pdf轉換成功,PDF輸出:"+pdfFile.getPath()+"****");
}catch(java.net.ConnectExceptione){
e.printStackTrace();
System.out.println("****swf轉換器異常,openoffice服務未啟動!****");
throwe;
}catch(com.artofsolving.jodconverter.openoffice.connection.OpenOfficeExceptione){
e.printStackTrace();
System.out.println("****swf轉換器異常,讀取轉換文件失敗****");
throwe;
}catch(Exceptione){
e.printStackTrace();
throwe;
}
}else{
System.out.println("****已經轉換為pdf,不需要再進行轉化****");
}
}else{
System.out.println("****swf轉換器異常,需要轉換的文檔不存在,無法轉換****");
}
}

/**
*轉換成swf
*/
@SuppressWarnings("unused")
privatevoidpdf2swf()throwsException{
Runtimer=Runtime.getRuntime();
if(!swfFile.exists()){
if(pdfFile.exists()){
if(environment==1){//windows環境處理
try{
//Processp=r.exec("D:/ProgramFiles/SWFTools/pdf2swf.exe"+pdfFile.getPath()+"-o"+swfFile.getPath()+"-T9");
Processp=r.exec("C:/ProgramFiles(x86)/SWFTools/pdf2swf.exe"+pdfFile.getPath()+"-o"+swfFile.getPath()+"-T9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.out.print(loadStream(p.getInputStream()));
System.err.println("****swf轉換成功,文件輸出:"
+swfFile.getPath()+"****");
if(pdfFile.exists()){
pdfFile.delete();
}

}catch(IOExceptione){
e.printStackTrace();
throwe;
}
}elseif(environment==2){//linux環境處理
try{
Processp=r.exec("pdf2swf"+pdfFile.getPath()
+"-o"+swfFile.getPath()+"-T9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.err.println("****swf轉換成功,文件輸出:"
+swfFile.getPath()+"****");
if(pdfFile.exists()){
pdfFile.delete();
}
}catch(Exceptione){
e.printStackTrace();
throwe;
}
}
}else{
System.out.println("****pdf不存在,無法轉換****");
}
}else{
System.out.println("****swf已經存在不需要轉換****");
}
}

staticStringloadStream(InputStreamin)throwsIOException{

intptr=0;
in=newBufferedInputStream(in);
StringBufferbuffer=newStringBuffer();

while((ptr=in.read())!=-1){
buffer.append((char)ptr);
}

returnbuffer.toString();
}
/**
*轉換主方法
*/
@SuppressWarnings("unused")
publicbooleanconver(){

if(swfFile.exists()){
System.out.println("****swf轉換器開始工作,該文件已經轉換為swf****");
returntrue;
}

if(environment==1){
System.out.println("****swf轉換器開始工作,當前設置運行環境windows****");
}else{
System.out.println("****swf轉換器開始工作,當前設置運行環境linux****");
}
try{
doc2pdf();
pdf2swf();
}catch(Exceptione){
e.printStackTrace();
returnfalse;
}

if(swfFile.exists()){
returntrue;
}else{
returnfalse;
}
}

/**
*返迴文件路徑
*
*@params
*/
publicStringgetswfPath(){
if(swfFile.exists()){
StringtempString=swfFile.getPath();
tempString=tempString.replaceAll("\\","/");
returntempString;
}else{
return"";
}

}
/**
*設置輸出路徑
*/
publicvoidsetOutputPath(StringoutputPath){
this.outputPath=outputPath;
if(!outputPath.equals("")){
StringrealName=fileName.substring(fileName.lastIndexOf("/"),
fileName.lastIndexOf("."));
if(outputPath.charAt(outputPath.length())=='/'){
swfFile=newFile(outputPath+realName+".swf");
}else{
swfFile=newFile(outputPath+realName+".swf");
}
}
}

}

轉換為PDF,然後轉換為SWF,網上很多這個過程的代碼,你可以看看

閱讀全文

與linux安裝swftools相關的資料

熱點內容
交換伴侶電影推薦 瀏覽:323
許燕pdf 瀏覽:697
百度app如何查電費 瀏覽:482
本機上的伺服器ip地址是多少個 瀏覽:446
每天讀點英文pdf 瀏覽:967
php字典排序函數 瀏覽:986
三星a60相冊可以加密嗎 瀏覽:76
python命令行utf8 瀏覽:551
幹部任用滿三年的演算法 瀏覽:485
人體露點的電影 瀏覽:639
可以解壓的小雞 瀏覽:959
冰箱壓縮機降溫 瀏覽:905
ipad如何只使用固定app 瀏覽:978
如何拼合pdf文件 瀏覽:771
啄木鳥電影大合集 瀏覽:987
php網頁如何修改 瀏覽:314
愛倫坡全集pdf 瀏覽:128
在伺服器怎麼弄32k鑽石劍 瀏覽:144
食物鏈電視劇韓國演員 瀏覽:116
vp電視劇網站免費 瀏覽:161