分离tl-server和server中接口的非公共方法,将公共方法wordToPdf放到BaseDocumentService中

BaseDocumentService.java中增加doc转docx、xls转xlsx的方法
BaseDocumentService.java中增加convert方法
This commit is contained in:
杨黄林
2022-12-28 18:23:55 +08:00
parent f38fd6e635
commit 820c307e89
8 changed files with 269 additions and 120 deletions

View File

@@ -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转pdfserver和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转为docxserver和tl-server下均实现
*
* @param docData doc文档流
* @return docx文档流
*/
default byte[] docToDocx(byte[] docData) {
throw new UnsupportedOperationException();
}
/**
* xls转为xlsxserver和tl-server下均实现
*
* @param xlsData xls文档流
* @return xlsx文档流
*/
default byte[] xlsToXlsx(byte[] xlsData) {
throw new UnsupportedOperationException();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}