commit
fa2a2b4342
|
@ -142,3 +142,19 @@ pdf2jpg.dpi = ${KK_PDF2JPG_DPI:144}
|
||||||
office.type.web = ${KK_OFFICE_TYPE_WEB:web}
|
office.type.web = ${KK_OFFICE_TYPE_WEB:web}
|
||||||
#Cad类型图片浏览模式:tif(利用前端js插件浏览);svg(转换为svg显示);pdf(转换为pdf后显示,便于打印)
|
#Cad类型图片浏览模式:tif(利用前端js插件浏览);svg(转换为svg显示);pdf(转换为pdf后显示,便于打印)
|
||||||
cad.preview.type = ${KK_CAD_PREVIEW_TYPE:pdf}
|
cad.preview.type = ${KK_CAD_PREVIEW_TYPE:pdf}
|
||||||
|
|
||||||
|
#OFFICE转换模块设置
|
||||||
|
#生成限制 默认不限制 使用方法 (1-5)
|
||||||
|
office.pagerange = ${KK_OFFICE_PAGERANGE:false}
|
||||||
|
#生成水印 默认不启用 使用方法 (kkFileView)
|
||||||
|
office.watermark = ${KK_OFFICE_WATERMARK:false}
|
||||||
|
#OFFICE JPEG图片压缩
|
||||||
|
office.quality = ${KK_OFFICE_QUALITY:80}
|
||||||
|
#图像分辨率限制
|
||||||
|
office.maximageresolution = ${KK_OFFICE_MAXIMAGERESOLUTION:150}
|
||||||
|
#导出书签
|
||||||
|
office.exportbookmarks = ${KK_OFFICE_EXPORTBOOKMARKS:true}
|
||||||
|
#批注作为PDF的注释
|
||||||
|
office.exportnotes = ${KK_OFFICE_EXPORTNOTES:true}
|
||||||
|
#加密文档 生成的PDF文档 添加密码(密码为加密文档的密码)
|
||||||
|
office.documentopenpasswords = ${KK_OFFICE_DOCUMENTOPENPASSWORD:true}
|
||||||
|
|
|
@ -51,6 +51,13 @@ public class ConfigConstants {
|
||||||
private static String cadPreviewType;
|
private static String cadPreviewType;
|
||||||
private static Boolean deleteSourceFile;
|
private static Boolean deleteSourceFile;
|
||||||
private static Boolean deleteCaptcha;
|
private static Boolean deleteCaptcha;
|
||||||
|
private static String officePageRange;
|
||||||
|
private static String officeWatermark;
|
||||||
|
private static String officeQuality;
|
||||||
|
private static String officeMaxImageResolution;
|
||||||
|
private static Boolean officeExportBookmarks;
|
||||||
|
private static Boolean officeExportNotes;
|
||||||
|
private static Boolean officeDocumentOpenPasswords;
|
||||||
|
|
||||||
public static final String DEFAULT_CACHE_ENABLED = "true";
|
public static final String DEFAULT_CACHE_ENABLED = "true";
|
||||||
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
||||||
|
@ -81,6 +88,15 @@ public class ConfigConstants {
|
||||||
public static final String DEFAULT_DELETE_SOURCE_FILE = "true";
|
public static final String DEFAULT_DELETE_SOURCE_FILE = "true";
|
||||||
public static final String DEFAULT_DELETE_CAPTCHA = "false";
|
public static final String DEFAULT_DELETE_CAPTCHA = "false";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String DEFAULT_OFFICE_PAQERANQE = "false";
|
||||||
|
public static final String DEFAULT_OFFICE_WATERMARK = "false";
|
||||||
|
public static final String DEFAULT_OFFICE_QUALITY = "80";
|
||||||
|
public static final String DEFAULT_OFFICE_MAXIMAQERESOLUTION = "150";
|
||||||
|
public static final String DEFAULT_OFFICE_EXPORTBOOKMARKS = "true";
|
||||||
|
public static final String DEFAULT_OFFICE_EXPORTNOTES = "true";
|
||||||
|
public static final String DEFAULT_OFFICE_EOCUMENTOPENPASSWORDS = "true";
|
||||||
|
|
||||||
public static Boolean isCacheEnabled() {
|
public static Boolean isCacheEnabled() {
|
||||||
return cacheEnabled;
|
return cacheEnabled;
|
||||||
}
|
}
|
||||||
|
@ -478,4 +494,86 @@ public class ConfigConstants {
|
||||||
public static void setDeleteCaptchaValue(Boolean deleteCaptcha) {
|
public static void setDeleteCaptchaValue(Boolean deleteCaptcha) {
|
||||||
ConfigConstants.deleteCaptcha = deleteCaptcha;
|
ConfigConstants.deleteCaptcha = deleteCaptcha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以下为OFFICE转换模块设置
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static String getOfficePageRange() {
|
||||||
|
return officePageRange;
|
||||||
|
}
|
||||||
|
@Value("${office.pagerange:false}")
|
||||||
|
public void setOfficePageRange(String officePageRange) {
|
||||||
|
setOfficePageRangeValue(officePageRange);
|
||||||
|
}
|
||||||
|
public static void setOfficePageRangeValue(String officePageRange) {
|
||||||
|
ConfigConstants.officePageRange = officePageRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOfficeWatermark() {
|
||||||
|
return officeWatermark;
|
||||||
|
}
|
||||||
|
@Value("${office.watermark:false}")
|
||||||
|
public void setOfficeWatermark(String officeWatermark) {
|
||||||
|
setOfficeWatermarkValue(officeWatermark);
|
||||||
|
}
|
||||||
|
public static void setOfficeWatermarkValue(String officeWatermark) {
|
||||||
|
ConfigConstants.officeWatermark = officeWatermark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOfficeQuality() {
|
||||||
|
return officeQuality;
|
||||||
|
}
|
||||||
|
@Value("${office.quality:80}")
|
||||||
|
public void setOfficeQuality(String officeQuality) {
|
||||||
|
setOfficeQualityValue(officeQuality);
|
||||||
|
}
|
||||||
|
public static void setOfficeQualityValue(String officeQuality) {
|
||||||
|
ConfigConstants.officeQuality = officeQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOfficeMaxImageResolution() {
|
||||||
|
return officeMaxImageResolution;
|
||||||
|
}
|
||||||
|
@Value("${office.maximageresolution:150}")
|
||||||
|
public void setOfficeMaxImageResolution(String officeMaxImageResolution) {
|
||||||
|
setOfficeMaxImageResolutionValue(officeMaxImageResolution);
|
||||||
|
}
|
||||||
|
public static void setOfficeMaxImageResolutionValue(String officeMaxImageResolution) {
|
||||||
|
ConfigConstants.officeMaxImageResolution = officeMaxImageResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getOfficeExportBookmarks() {
|
||||||
|
return officeExportBookmarks;
|
||||||
|
}
|
||||||
|
@Value("${office.exportbookmarks:true}")
|
||||||
|
public void setOfficeExportBookmarks(Boolean officeExportBookmarks) {
|
||||||
|
setOfficeExportBookmarksValue(officeExportBookmarks);
|
||||||
|
}
|
||||||
|
public static void setOfficeExportBookmarksValue(Boolean officeExportBookmarks) {
|
||||||
|
ConfigConstants.officeExportBookmarks = officeExportBookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getOfficeExportNotes() {
|
||||||
|
return officeExportNotes;
|
||||||
|
}
|
||||||
|
@Value("${office.exportnotes:true}")
|
||||||
|
public void setExportNotes(Boolean officeExportNotes) {
|
||||||
|
setOfficeExportNotesValue(officeExportNotes);
|
||||||
|
}
|
||||||
|
public static void setOfficeExportNotesValue(Boolean officeExportNotes) {
|
||||||
|
ConfigConstants.officeExportNotes = officeExportNotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getOfficeDocumentOpenPasswords() {
|
||||||
|
return officeDocumentOpenPasswords;
|
||||||
|
}
|
||||||
|
@Value("${office.documentopenpasswords:true}")
|
||||||
|
public void setDocumentOpenPasswords(Boolean officeDocumentOpenPasswords) {
|
||||||
|
setOfficeDocumentOpenPasswordsValue(officeDocumentOpenPasswords);
|
||||||
|
}
|
||||||
|
public static void setOfficeDocumentOpenPasswordsValue(Boolean officeDocumentOpenPasswords) {
|
||||||
|
ConfigConstants.officeDocumentOpenPasswords = officeDocumentOpenPasswords;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,13 @@ public class ConfigRefreshComponent {
|
||||||
String cadPreviewType;
|
String cadPreviewType;
|
||||||
boolean deleteSourceFile;
|
boolean deleteSourceFile;
|
||||||
boolean deleteCaptcha;
|
boolean deleteCaptcha;
|
||||||
|
String officPageRange;
|
||||||
|
String officWatermark;
|
||||||
|
String officQuality;
|
||||||
|
String officMaxImageResolution;
|
||||||
|
boolean officExportBookmarks;
|
||||||
|
boolean officeExportNotes;
|
||||||
|
boolean officeDocumentOpenPasswords;
|
||||||
while (true) {
|
while (true) {
|
||||||
FileReader fileReader = new FileReader(configFilePath);
|
FileReader fileReader = new FileReader(configFilePath);
|
||||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||||
|
@ -96,6 +103,13 @@ public class ConfigRefreshComponent {
|
||||||
officeTypeWeb = properties.getProperty("office.type.web", ConfigConstants.DEFAULT_OFFICE_TYPE_WEB);
|
officeTypeWeb = properties.getProperty("office.type.web", ConfigConstants.DEFAULT_OFFICE_TYPE_WEB);
|
||||||
deleteSourceFile = Boolean.parseBoolean(properties.getProperty("delete.source.file", ConfigConstants.DEFAULT_DELETE_SOURCE_FILE));
|
deleteSourceFile = Boolean.parseBoolean(properties.getProperty("delete.source.file", ConfigConstants.DEFAULT_DELETE_SOURCE_FILE));
|
||||||
deleteCaptcha = Boolean.parseBoolean(properties.getProperty("delete.captcha", ConfigConstants.DEFAULT_DELETE_CAPTCHA));
|
deleteCaptcha = Boolean.parseBoolean(properties.getProperty("delete.captcha", ConfigConstants.DEFAULT_DELETE_CAPTCHA));
|
||||||
|
officPageRange = properties.getProperty("office.pagerange", ConfigConstants.DEFAULT_OFFICE_PAQERANQE);
|
||||||
|
officWatermark = properties.getProperty("office.watermark", ConfigConstants.DEFAULT_OFFICE_WATERMARK);
|
||||||
|
officQuality = properties.getProperty("office.quality", ConfigConstants.DEFAULT_OFFICE_QUALITY);
|
||||||
|
officMaxImageResolution = properties.getProperty("office.maximageresolution", ConfigConstants.DEFAULT_OFFICE_MAXIMAQERESOLUTION);
|
||||||
|
officExportBookmarks = Boolean.parseBoolean(properties.getProperty("office.exportbookmarks", ConfigConstants.DEFAULT_OFFICE_EXPORTBOOKMARKS));
|
||||||
|
officeExportNotes = Boolean.parseBoolean(properties.getProperty("office.exportnotes", ConfigConstants.DEFAULT_OFFICE_EXPORTNOTES));
|
||||||
|
officeDocumentOpenPasswords = Boolean.parseBoolean(properties.getProperty("office.documentopenpasswords", ConfigConstants.DEFAULT_OFFICE_EOCUMENTOPENPASSWORDS));
|
||||||
prohibitArray = prohibit.split(",");
|
prohibitArray = prohibit.split(",");
|
||||||
|
|
||||||
ConfigConstants.setCacheEnabledValueValue(cacheEnabled);
|
ConfigConstants.setCacheEnabledValueValue(cacheEnabled);
|
||||||
|
@ -122,6 +136,13 @@ public class ConfigRefreshComponent {
|
||||||
ConfigConstants.setPasswordValue(password);
|
ConfigConstants.setPasswordValue(password);
|
||||||
ConfigConstants.setPdf2JpgDpiValue(pdf2JpgDpi);
|
ConfigConstants.setPdf2JpgDpiValue(pdf2JpgDpi);
|
||||||
ConfigConstants.setOfficeTypeWebValue(officeTypeWeb);
|
ConfigConstants.setOfficeTypeWebValue(officeTypeWeb);
|
||||||
|
ConfigConstants.setOfficePageRangeValue(officPageRange);
|
||||||
|
ConfigConstants.setOfficeWatermarkValue(officWatermark);
|
||||||
|
ConfigConstants.setOfficeQualityValue(officQuality);
|
||||||
|
ConfigConstants.setOfficeMaxImageResolutionValue(officMaxImageResolution);
|
||||||
|
ConfigConstants.setOfficeExportBookmarksValue(officExportBookmarks);
|
||||||
|
ConfigConstants.setOfficeExportNotesValue(officeExportNotes);
|
||||||
|
ConfigConstants.setOfficeDocumentOpenPasswordsValue(officeDocumentOpenPasswords);
|
||||||
ConfigConstants.setDeleteSourceFileValue(deleteSourceFile);
|
ConfigConstants.setDeleteSourceFileValue(deleteSourceFile);
|
||||||
ConfigConstants.setDeleteCaptchaValue(deleteCaptcha);
|
ConfigConstants.setDeleteCaptchaValue(deleteCaptcha);
|
||||||
setWatermarkConfig(properties);
|
setWatermarkConfig(properties);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.keking.service;
|
package cn.keking.service;
|
||||||
|
|
||||||
|
import cn.keking.config.ConfigConstants;
|
||||||
import cn.keking.model.FileAttribute;
|
import cn.keking.model.FileAttribute;
|
||||||
import com.sun.star.document.UpdateDocMode;
|
import com.sun.star.document.UpdateDocMode;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -33,15 +34,36 @@ public class OfficeToPdfService {
|
||||||
logger.error("创建目录【{}】失败,请检查目录权限!",outputFilePath_end);
|
logger.error("创建目录【{}】失败,请检查目录权限!",outputFilePath_end);
|
||||||
}
|
}
|
||||||
LocalConverter.Builder builder;
|
LocalConverter.Builder builder;
|
||||||
|
Map<String, Object> filterData = new HashMap<>();
|
||||||
|
filterData.put("EncryptFile", true);
|
||||||
|
if(!ConfigConstants.getOfficePageRange().equals("false")){
|
||||||
|
filterData.put("PageRange", ConfigConstants.getOfficePageRange()); //限制页面
|
||||||
|
}
|
||||||
|
if(!ConfigConstants.getOfficeWatermark().equals("false")){
|
||||||
|
filterData.put("Watermark", ConfigConstants.getOfficeWatermark()); //水印
|
||||||
|
}
|
||||||
|
filterData.put("Quality", ConfigConstants.getOfficeQuality()); //图片压缩
|
||||||
|
filterData.put("MaxImageResolution", ConfigConstants.getOfficeMaxImageResolution()); //DPI
|
||||||
|
if(ConfigConstants.getOfficeExportBookmarks()){
|
||||||
|
filterData.put("ExportBookmarks", true); //导出书签
|
||||||
|
}
|
||||||
|
if(ConfigConstants.getOfficeExportNotes()){
|
||||||
|
filterData.put("ExportNotes", true); //批注作为PDF的注释
|
||||||
|
}
|
||||||
|
if(!ConfigConstants.getOfficeDocumentOpenPasswords()){
|
||||||
|
filterData.put("DocumentOpenPassword", fileAttribute.getFilePassword()); //给PDF添加密码
|
||||||
|
}
|
||||||
|
Map<String, Object> customProperties = new HashMap<>();
|
||||||
|
customProperties.put("FilterData", filterData);
|
||||||
if (StringUtils.isNotBlank(fileAttribute.getFilePassword())) {
|
if (StringUtils.isNotBlank(fileAttribute.getFilePassword())) {
|
||||||
Map<String, Object> loadProperties = new HashMap<>();
|
Map<String, Object> loadProperties = new HashMap<>();
|
||||||
loadProperties.put("Hidden", true);
|
loadProperties.put("Hidden", true);
|
||||||
loadProperties.put("ReadOnly", true);
|
loadProperties.put("ReadOnly", true);
|
||||||
loadProperties.put("UpdateDocMode", UpdateDocMode.NO_UPDATE);
|
loadProperties.put("UpdateDocMode", UpdateDocMode.NO_UPDATE);
|
||||||
loadProperties.put("Password", fileAttribute.getFilePassword());
|
loadProperties.put("Password", fileAttribute.getFilePassword());
|
||||||
builder = LocalConverter.builder().loadProperties(loadProperties);
|
builder = LocalConverter.builder().loadProperties(loadProperties).storeProperties(customProperties);
|
||||||
} else {
|
} else {
|
||||||
builder = LocalConverter.builder();
|
builder = LocalConverter.builder().storeProperties(customProperties);
|
||||||
}
|
}
|
||||||
builder.build().convert(inputFile).to(outputFile).execute();
|
builder.build().convert(inputFile).to(outputFile).execute();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue