分离tl-server和server中接口的非公共方法,将公共方法wordToPdf放到BaseDocumentService中
BaseDocumentService.java中增加doc转docx、xls转xlsx的方法 BaseDocumentService.java中增加convert方法
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package com.optima.document.api;
|
||||
|
||||
/**
|
||||
* @author yanghuanglin
|
||||
* @since 2022/12/28
|
||||
*/
|
||||
public interface BaseDocumentService {
|
||||
/**
|
||||
* 格式转换,server和tl-server下均实现
|
||||
*
|
||||
* @param sourceData 源文件流,tl-server下仅支持docx格式
|
||||
* @param sourceExtension 源文件后缀名,不包含"."
|
||||
* @param targetExtension 目标文件后缀名,不包含"."
|
||||
* @param targetFormat 目标文件格式
|
||||
* @return 转换后的文件流
|
||||
*/
|
||||
default byte[] convert(byte[] sourceData, String sourceExtension, String targetExtension, String targetFormat) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通word转pdf,server和tl-server下均实现
|
||||
*
|
||||
* @param source 源文件流,tl-server下仅支持docx格式
|
||||
* @param sourceFormat 源文件后缀名,不包含".",tl-server下可忽略
|
||||
* @param clear 是否清除占位符
|
||||
* @return pdf文档流
|
||||
*/
|
||||
default byte[] wordToPdf(byte[] source, String sourceFormat, boolean clear) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* doc转为docx,server和tl-server下均实现
|
||||
*
|
||||
* @param docData doc文档流
|
||||
* @return docx文档流
|
||||
*/
|
||||
default byte[] docToDocx(byte[] docData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* xls转为xlsx,server和tl-server下均实现
|
||||
*
|
||||
* @param xlsData xls文档流
|
||||
* @return xlsx文档流
|
||||
*/
|
||||
default byte[] xlsToXlsx(byte[] xlsData) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -1,71 +1,44 @@
|
||||
package com.optima.document.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文档接口
|
||||
* @author Elias
|
||||
* @date 2021-09-28 16:00
|
||||
* 文档接口,此类中用的poi2生成word文档,使用docto进行格式转换
|
||||
*
|
||||
* @author yanghuanglin
|
||||
* @since 2022/12/28
|
||||
*/
|
||||
public interface DocumentService {
|
||||
public interface DocumentService extends BaseDocumentService {
|
||||
/**
|
||||
* generate word
|
||||
* @param templateData word模版流
|
||||
* @param dataModel 数据模型
|
||||
* @return 修改后的文档流
|
||||
* 通过调用poi生成word,仅tl-server模块下实现,仅支持docx格式
|
||||
*
|
||||
* @param templateData word模版流,仅支持docx格式
|
||||
* @param dataModel 数据模型
|
||||
* @return word文档流
|
||||
*/
|
||||
default byte[] generateWord(byte[] templateData, Map<String, Object> dataModel) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* word to pdf
|
||||
* @param templateData word模版流
|
||||
* @param clear 是否清除占位符
|
||||
* @return
|
||||
* 通过调用poi将word转pdf,仅tl-server模块下实现,仅支持docx格式
|
||||
*
|
||||
* @param templateData word模版流,仅支持docx格式
|
||||
* @param clear 是否清除占位符
|
||||
* @return pdf文档流
|
||||
*/
|
||||
default byte[] wordToPdf(byte[] templateData, boolean clear) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* word to image
|
||||
* @param templateData word模版流
|
||||
* @param targetFormat 目标格式 支持jpeg, jpg, gif, tiff or png
|
||||
* @return
|
||||
*/
|
||||
default byte[] wordToImage(byte[] templateData, String targetFormat) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* word转图片,仅支持docx格式
|
||||
*
|
||||
* @param source 文档
|
||||
* @param toFindText 需要替换的文本
|
||||
* @param imgSource 图片
|
||||
* @param width 宽度
|
||||
* @param height 高度
|
||||
* @return 修改后的文档
|
||||
* @param source word文件流,仅支持docx格式
|
||||
* @param targetExtension 目标格式 支持jpeg, jpg, gif, tiff or png
|
||||
* @return 图片流
|
||||
*/
|
||||
default byte[] insertJpeg(byte[] source, String toFindText, byte[] imgSource, int width, int height){
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param source
|
||||
* @param toFindText
|
||||
* @param imgSource
|
||||
* @param width
|
||||
* @param height
|
||||
* @return
|
||||
*/
|
||||
default byte[] insertJpeg(byte[] source, String toFindText, List<byte[]> imgSource, int width, int height) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
default byte[] fieldToWord(byte[] source, Map<String, Object> infoMap) {
|
||||
default byte[] wordToImage(byte[] source, String targetExtension) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.optima.document.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文档接口,此类中用的jacob生成word文档,插入图片等,使用openoffice进行格式转换
|
||||
*
|
||||
* @author Elias
|
||||
* @since 2021-09-28 16:00
|
||||
*/
|
||||
public interface LegacyDocumentService extends BaseDocumentService {
|
||||
/**
|
||||
* 通过pdfbox将word转图片,仅server模块下实现
|
||||
*
|
||||
* @param templateData word模版流
|
||||
* @param sourceExtension 源文件后缀名,不包含"."
|
||||
* @param targetExtension 目标格式 支持jpeg, jpg, gif, tiff or png
|
||||
* @return 图片流
|
||||
*/
|
||||
default byte[] wordToImage(byte[] templateData, String sourceExtension, String targetExtension) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过jacob向文档中插入图片,仅server模块下实现
|
||||
*
|
||||
* @param source 文档流
|
||||
* @param toFindText 需要替换的文本
|
||||
* @param imgSource 图片流
|
||||
* @param width 宽度
|
||||
* @param height 高度
|
||||
* @return word文档流
|
||||
*/
|
||||
default byte[] insertJpeg(byte[] source, String toFindText, byte[] imgSource, int width, int height) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过jacob向文档中插入多张图片,仅server模块下实现
|
||||
*
|
||||
* @param source 文档流
|
||||
* @param toFindText 需要替换的文本
|
||||
* @param imgSource 图片流列表
|
||||
* @param width 宽度
|
||||
* @param height 高度
|
||||
* @return word文档流
|
||||
*/
|
||||
default byte[] insertJpeg(byte[] source, String toFindText, List<byte[]> imgSource, int width, int height) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过jacob向word填充属性字段,仅server模块下实现
|
||||
*
|
||||
* @param source 文档流
|
||||
* @param infoMap 字段集合,${key}为占位字符,value为对应替换内容
|
||||
* @return word文档流
|
||||
*/
|
||||
default byte[] fieldToWord(byte[] source, Map<String, Object> infoMap) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user