欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java仿文庫的基本方法(openoffice+swftools+flexPaper)

 更新時(shí)間:2017年02月04日 10:50:08   作者:Joker_Ye  
這篇文章主要為大家詳細(xì)介紹了Java仿文庫的基本方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

Java仿文庫的基本方法

基本步驟:

    1、將要展示的office文件 轉(zhuǎn)換成 PDF,  使用工具 openoffice 

    2、將PDF文件轉(zhuǎn)換成swf ,實(shí)用工具swftools

    3、使用flexPaper,顯示轉(zhuǎn)換后的swf文件。

基礎(chǔ)代碼:沒有任何校驗(yàn)

1、openoffice轉(zhuǎn)換pdf

下載地址:https://www.openoffice.org/zh-cn/

實(shí)用工具:  jodconverter-2.2.2   引入所需jar,直接將所有jar都扔進(jìn)來了

首先、下載openOffice軟件,并安裝,使用dos命令開啟服務(wù),就是cmd了,我安裝在了C盤

命令如下:執(zhí)行效果

C:\Program Files (x86)\OpenOffice 4\program>soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard 

啟動(dòng)后,執(zhí)行以下命令    doc文件為原始文件,轉(zhuǎn)換成pdf

File inputFile = new File("D:\\大數(shù)據(jù)及應(yīng)用.doc"); 
 File outputFile = new File("D:\\大數(shù)據(jù)及應(yīng)用.pdf"); 
 OpenOfficeConnection connection = new SocketOpenOfficeConnection( 
   "127.0.0.1", 8100); 
  connection.connect(); 
 
  // convert 
 DocumentConverter converter = new OpenOfficeDocumentConverter( 
   connection); 
 converter.convert(inputFile, outputFile); 
 
 // close the connection 
 connection.disconnect(); 

2、swftools將PDF轉(zhuǎn)換swf

下載地址:http://www.swftools.org/download.html

    首先安裝swftools工具,我是windows 下載exe文件,直接安裝,

    注:文件夾不要有空格,有空格不識(shí)別  如  program file  文件夾下 不好使

    我安裝在了D盤根目錄下,該方法來源于網(wǎng)絡(luò),資料找的太多不記得從哪位大俠哪拷來得了,

    還要注意下面代碼被我改成windows的命令了,linux不生效。

public static int convertPDF2SWF(String sourcePath, String destPath, String fileName) throws IOException { 
  //目標(biāo)路徑不存在則建立目標(biāo)路徑  
  File dest = new File(destPath);  
  if (!dest.exists()) dest.mkdirs();    
  //源文件不存在則返回  
  File source = new File(sourcePath);  
  if (!source.exists()) return 0;    
  //調(diào)用pdf2swf命令進(jìn)行轉(zhuǎn)換  
  String command = "D:\\SWFTools\\pdf2swf.exe " + sourcePath + " -o " + destPath + fileName + " -f -T 9 " ; 
  System.out.println(command); 
  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();   
  } 


4、flexPaper顯示swf

    下載地址:http://static.devaldi.com/GPL/FlexPaper_2.2.4.zip

    jsp代碼如下

    該文件:FlexPaperViewer.swf

<!--首先要引入jquery庫及相關(guān)的js 下載包里面 找--> 
<script type="text/javascript" src="js/jquery.js"></script> 
<script type="text/javascript" src="js/flexpaper_flash.js"></script> 
<script type="text/javascript" src="js/flexpaper_flash_debug.js"></script> 

body內(nèi)如下  

 <div style="position:absolute;left:10px;top:10px;"> 
  <a id="viewerPlaceHolder" style="width:1260px;height:780px;display:block"></a>  
  <script type="text/javascript"> 
  var fp = new FlexPaperViewer( 
    'FlexPaperViewer', 
    'viewerPlaceHolder', <!--對應(yīng)于a 標(biāo)簽的id--> 
    { config : { 
    SwfFile : decodeURI('aaa.swf'), <!--引入的swf文件,decodeURI 解決中文文件名問題--> 
    Scale : 0.6, 
    ZoomTransition : 'easeOut', 
    ZoomTime : 0.5, 
    ZoomInterval : 0.2, 
    FitPageOnLoad : true, 
    FitWidthOnLoad : false, 
    PrintEnabled : true, 
    FullScreenAsMaxWindow : false, 
    ProgressiveLoading : false, 
    MinZoomSize : 0.2, 
    MaxZoomSize : 5, 
    SearchMatchAll : false, 
    InitViewMode : 'Portrait', 
    
    ViewModeToolsVisible : true, 
    ZoomToolsVisible : true, 
    NavToolsVisible : true, 
    CursorToolsVisible : true, 
    SearchToolsVisible : true, 
    localeChain: 'zh_CN' <!--改成這個(gè)顯示中文--> 
    }}); 
  </script> 
 </div> 

執(zhí)行效果:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論