bboss libreoffice结合使用说明

简介: bboss libreoffice结合使用说明已经文件下载插件完善 最近增加工具类/bboss-plugin-wordpdf/src/org/frameworkset/http/converter/wordpdf/FileConvertor.
bboss libreoffice结合使用说明已经文件下载插件完善
最近增加工具类 /bboss-plugin-wordpdf/src/org/frameworkset/http/converter/wordpdf/FileConvertor.java
通过jodconvertor组件结合,利用libreoffice实现word模板书签和值合并功能
方便地借助swftool和Flashprinter实现word向pdf,swf的转换

o 文件下载插件增加对FileBlob的支持
FileBlob增加构造函数:
public FileBlob( File data,int rendtype)
public FileBlob( String file,int rendtype)
两个构造函数含义是一致的,参数说明:
第一个参数:下载或者浏览的文件对象或者文件路径
第二个参数:标识文件是用来下载还是用来浏览,对应于FileBlob中的两个常量:FileBlob.BROWSER,FileBlob.DOWNLOAD,默认值为FileBlob.DOWNLOAD

使用实例一,控制器下载文件方法

public @ResponseBody FileBlob downloadSWFTempAllUseOpenOffice() throws Exception  {
		System.out.println("--------------程序执行到此处------------------");
		String[] bookMarks = new String[] { "DealerName", "Name", "CgName",
				"TypeName", "OrderQty", "CoolCode", "ChassisCode", "CustPrice",
				"CustAmt", "sumall", "EarnestPayDays", "EarnestAmt",
				"StageDate", "FirstAmt", "DepositPercent", "Deposit",
				"ServiceChargePercent", "ServiceCharge", "NotarizationFee",
				"InsuranceTerm", "Insurance", "ReinsuranceDeposit",
				"FinanceAmt", "FinanceFC", "LackAmtPayDate",
				"LackAmtFinalPayDate", "ReceiverName", "ReceiverID",   
				"ReceiverTel", "Insurer","authoriate" };
		String[] mapValue = new String[] { "工程机械有限公司", "工程机械有限公司",
				"六桥车", "xxx52E(6)", "2", "风冷", "V09660ffff", "300.00",
				"600.00", "陆万元整", "7", "100", "2000年8月31日", "60", "5", "3",
				"10", "6", "10", "5", "10", "21", "540", "10", "2000年8月31日",
				"2000年8月31日", "xxx", "430111199910102121", "13800138200", "xxxxx","bboss" };
		String hetongbianhao = "20121222";
	    String wordtemplate = "/opt/tomcat/wordpdf/anjie.doc";
	    String pdfpath = "/opt/tomcat/test/anjieswftools_" + hetongbianhao + ".pdf";
	    String wordfile = "/opt/tomcat/test/anjie_testswftools" + hetongbianhao + ".doc";
	    String toswfpath = "/opt/tomcat/test/contractswftools_" + hetongbianhao + ".swf";

		String officeHome = "/opt/LibreOffice 3.6/";
		File f = new File(toswfpath);
		if(!f.exists())
		{

			FileConvertor.init( officeHome);
						
			FileConvertor.getRealWordByOpenoffice(wordtemplate, wordfile,bookMarks, bookdatas);
			FileConvertor.wordToPDFByOpenOffice(wordfile, pdfpath);
			FileConvertor.swftoolsConvert(swftoolWorkDir, pdfpath, toswfpath);
			
		}		
		FileBlob fileblob = new FileBlob(toswfpath,FileBlob.DOWNLOAD);
		return fileblob;
		
		

	}	

实例二,结合wordpdfswf插件生成swf文件并在界面上展示
public @ResponseBody FileBlob getSWFTemp() throws Exception  {
		System.out.println("--------------程序执行到此处------------------");
		String[] bookMarks = new String[] { "DealerName", "Name", "CgName",
				"TypeName", "OrderQty", "CoolCode", "ChassisCode", "CustPrice",
				"CustAmt", "sumall", "EarnestPayDays", "EarnestAmt",
				"StageDate", "FirstAmt", "DepositPercent", "Deposit",
				"ServiceChargePercent", "ServiceCharge", "NotarizationFee",
				"InsuranceTerm", "Insurance", "ReinsuranceDeposit",
				"FinanceAmt", "FinanceFC", "LackAmtPayDate",
				"LackAmtFinalPayDate", "ReceiverName", "ReceiverID",   
				"ReceiverTel", "Insurer","authoriate" };
		String[] mapValue = new String[] { "工程机械有限公司", "工程机械有限公司",
				"六桥车", "xxx", "2", "风冷", "V09660", "300.00",
				"600.00", "陆万元整", "7", "100", "2000年8月31日", "60", "5", "3",
				"10", "6", "10", "5", "10", "21", "540", "10", "2000年8月31日",
				"2000年8月31日", "xxx", "430111199910102121", "13800138200", "xxx","bboss" };
		String hetongbianhao = "20121222";
	    String wordtemplate = "/opt/tomcat/wordpdf/anjie.doc";
	    String pdfpath = "/opt/tomcat/test/anjieswftools_" + hetongbianhao + ".pdf";
	    String wordfile = "/opt/tomcat/test/anjie_testswftools" + hetongbianhao + ".doc";
	    String toswfpath = "/opt/tomcat/test/contractswftools_" + hetongbianhao + ".swf";

		String officeHome = "/opt/LibreOffice 3.6/";
		File f = new File(toswfpath);
		if(!f.exists())
		{

			FileConvertor.init( officeHome);
						
			FileConvertor.getRealWordByOpenoffice(wordtemplate, wordfile,bookMarks, bookdatas);
			FileConvertor.wordToPDFByOpenOffice(wordfile, pdfpath);
			FileConvertor.swftoolsConvert(swftoolWorkDir, pdfpath, toswfpath);
			
		}		
		FileBlob fileblob = new FileBlob(toswfpath,FileBlob.BROWSER);
		return fileblob;
		

	}

注意我们这里使用了bboss 的word转pdf、swf插件FileConvertor
我们看看怎样通过FlashPlayer来展示生成的swf文件:
<%@ page contentType="text/html; charset=utf-8"%>
<html>
<head>
<title></title>
</head>
<body marginwidth="0" marginheight="0">
	
<embed height="100%" width="100%" name="plugin" src="getSWFTemp.page"
				type="application/x-shockwave-flash">
</body>
</html>

其中的src="getSWFTemp.page"就对应实例三中的控制器方法。
目录
相关文章
|
算法 Java 数据安全/隐私保护
Geoserver系列教程
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gisdoer/article/details/82415711 Geoserver使用系列教程 依据Geoserver官方文档制作的全系列教程持续更新中。
2484 0
|
自然语言处理 测试技术
Wix 安装部署教程(十六) -- 自动生成多语言文件
原文:Wix 安装部署教程(十六) -- 自动生成多语言文件      因为持续集成需要,所有项目编译完之后生成一个多语言的安装包。之前生成mst文件都是手动操作,而且mst文件必须每次重新和新的安装包“关联”,否则中文的安装包去调用英文的资源的时候就会报类似于“类型转换失败”的错误。
1228 0
|
XML 数据安全/隐私保护 数据格式
Wix 安装部署教程(八) 自动生成XML小工具
原文:Wix 安装部署教程(八) 自动生成XML小工具     这个功能类似于Heat.exe,指定文件夹,生成对应的WIX标签。Winform做的,代码简单,生成的标签需要粘贴到对应的目录才能使用,并不是一步到位。
1104 0