将wordToImage做为公共方法放到BaseDocumentService中

代码调整
This commit is contained in:
杨黄林
2022-12-29 10:19:05 +08:00
parent 820c307e89
commit 4b0b792e81
5 changed files with 62 additions and 55 deletions

View File

@@ -8,45 +8,59 @@ public interface BaseDocumentService {
/**
* 格式转换server和tl-server下均实现
*
* @param sourceData 源文件流tl-server下仅支持docx格式
* @param source 源文件流tl-server下仅支持docx格式
* @param sourceExtension 源文件后缀名,不包含"."
* @param targetExtension 目标文件后缀名,不包含"."
* @param targetFormat 目标文件格式
* @param targetFormat 目标文件格式需与目标文件后缀名匹配server下此参数无效。tl-server下参考: <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word.wdsaveformat">word格式</a>
* 或 <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.xlfileformat">excel格式</a>
* 或 <a href="https://docs.microsoft.com/en-us/office/vba/api/powerpoint.presentation.saveas">powerpoint格式</a>
* @return 转换后的文件流
*/
default byte[] convert(byte[] sourceData, String sourceExtension, String targetExtension, String targetFormat) {
default byte[] convert(byte[] source, String sourceExtension, String targetExtension, String targetFormat) {
throw new UnsupportedOperationException();
}
/**
* word转pdfserver和tl-server下均实现
* word转pdfserver和tl-server下均实现
*
* @param source 文件流tl-server下仅支持docx格式
* @param sourceFormat 源文件后缀名,不包含"."tl-server下可忽略
* @param clear 是否清除占位符
* @param source word文件流tl-server下仅支持docx格式
* @param sourceFormat 源文件后缀名,不包含"."tl-server下此参数无效
* @param clear 是否清除占位符如果为true则在tl-server下源文件只支持docx格式
* @return pdf文档流
*/
default byte[] wordToPdf(byte[] source, String sourceFormat, boolean clear) {
throw new UnsupportedOperationException();
}
/**
* 通过pdfbox将word转图片
*
* @param source word文件流tl-server下仅支持docx格式
* @param sourceExtension 源文件后缀名,不包含"."server下此参数无效
* @param targetExtension 目标格式 支持jpeg, jpg, gif, tiff or png
* @return 图片流
*/
default byte[] wordToImage(byte[] source, String sourceExtension, String targetExtension) {
throw new UnsupportedOperationException();
}
/**
* doc转为docxserver和tl-server下均实现
*
* @param docData doc文档流
* @param source doc文档流
* @return docx文档流
*/
default byte[] docToDocx(byte[] docData) {
default byte[] docToDocx(byte[] source) {
throw new UnsupportedOperationException();
}
/**
* xls转为xlsxserver和tl-server下均实现
*
* @param xlsData xls文档流
* @param source xls文档流
* @return xlsx文档流
*/
default byte[] xlsToXlsx(byte[] xlsData) {
default byte[] xlsToXlsx(byte[] source) {
throw new UnsupportedOperationException();
}
}

View File

@@ -12,27 +12,27 @@ public interface DocumentService extends BaseDocumentService {
/**
* 通过调用poi生成word仅tl-server模块下实现仅支持docx格式
*
* @param templateData word模版流仅支持docx格式
* @param dataModel 数据模型
* @param sourceTemplate word模版流仅支持docx格式
* @param dataModel 数据模型
* @return word文档流
*/
default byte[] generateWord(byte[] templateData, Map<String, Object> dataModel) {
default byte[] generateWord(byte[] sourceTemplate, Map<String, Object> dataModel) {
throw new UnsupportedOperationException();
}
/**
* 通过调用poi将word转pdf仅tl-server模块下实现仅支持docx格式
* 通过调用poi将word转pdf仅tl-server模块下实现如果clear为true仅支持docx格式
*
* @param templateData word模版流仅支持docx格式
* @param clear 是否清除占位符
* @param source word模版流仅支持docx格式
* @param clear 是否清除占位符
* @return pdf文档流
*/
default byte[] wordToPdf(byte[] templateData, boolean clear) {
default byte[] wordToPdf(byte[] source, boolean clear) {
throw new UnsupportedOperationException();
}
/**
* word转图片仅支持docx格式
* 通过pdfbox将word转图片仅支持docx格式
*
* @param source word文件流仅支持docx格式
* @param targetExtension 目标格式 支持jpeg, jpg, gif, tiff or png

View File

@@ -10,18 +10,6 @@ import java.util.Map;
* @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模块下实现
*