Commit a535ebfe authored by 陈精华's avatar 陈精华 Committed by kl

新功能点:新增配置是否可以下载转换完成的pdf文件

parent 3e80590a
...@@ -53,6 +53,8 @@ simText = ${KK_SIMTEXT:txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,,ja ...@@ -53,6 +53,8 @@ simText = ${KK_SIMTEXT:txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,,ja
media = ${KK_MEDIA:mp3,wav,mp4,flv} media = ${KK_MEDIA:mp3,wav,mp4,flv}
#office类型文档(word ppt)样式,默认为图片(image),可配置为pdf(预览时也有按钮切换) #office类型文档(word ppt)样式,默认为图片(image),可配置为pdf(预览时也有按钮切换)
office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:image} office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:image}
#是否禁止下载转换生成的pdf文件
pdf.download.disable = ${KK_PDF_DOWNLOAD_DISABLE:true}
#预览源为FTP时 FTP用户名,可在ftp url后面加参数ftp.username=ftpuser指定,不指定默认用配置的 #预览源为FTP时 FTP用户名,可在ftp url后面加参数ftp.username=ftpuser指定,不指定默认用配置的
ftp.username = ${KK_FTP_USERNAME:ftpuser} ftp.username = ${KK_FTP_USERNAME:ftpuser}
...@@ -82,3 +84,4 @@ watermark.width = ${WATERMARK_WIDTH:180} ...@@ -82,3 +84,4 @@ watermark.width = ${WATERMARK_WIDTH:180}
watermark.height = ${WATERMARK_HEIGHT:80} watermark.height = ${WATERMARK_HEIGHT:80}
#水印倾斜度数,要求设置在大于等于0,小于90 #水印倾斜度数,要求设置在大于等于0,小于90
watermark.angle = ${WATERMARK_ANGLE:10} watermark.angle = ${WATERMARK_ANGLE:10}
...@@ -27,6 +27,7 @@ public class ConfigConstants { ...@@ -27,6 +27,7 @@ public class ConfigConstants {
private static String BASE_URL; private static String BASE_URL;
private static String FILE_DIR = OfficeUtils.getHomePath() + File.separator + "file" + File.separator; private static String FILE_DIR = OfficeUtils.getHomePath() + File.separator + "file" + File.separator;
private static CopyOnWriteArraySet<String> TRUST_HOST_SET; private static CopyOnWriteArraySet<String> TRUST_HOST_SET;
private static String PDF_DOWNLOAD_DISABLE;
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,,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,,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
...@@ -38,6 +39,7 @@ public class ConfigConstants { ...@@ -38,6 +39,7 @@ public class ConfigConstants {
public static final String DEFAULT_BASE_URL = "default"; public static final String DEFAULT_BASE_URL = "default";
public static final String DEFAULT_FILE_DIR_VALUE = "default"; public static final String DEFAULT_FILE_DIR_VALUE = "default";
public static final String DEFAULT_TRUST_HOST = "default"; public static final String DEFAULT_TRUST_HOST = "default";
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
public static Boolean isCacheEnabled() { public static Boolean isCacheEnabled() {
return CACHE_ENABLED; return CACHE_ENABLED;
...@@ -141,4 +143,18 @@ public class ConfigConstants { ...@@ -141,4 +143,18 @@ public class ConfigConstants {
private static void setTrustHostSet(CopyOnWriteArraySet<String> trustHostSet) { private static void setTrustHostSet(CopyOnWriteArraySet<String> trustHostSet) {
ConfigConstants.TRUST_HOST_SET = trustHostSet; ConfigConstants.TRUST_HOST_SET = trustHostSet;
} }
public static String getPdfDownloadDisable() {
return PDF_DOWNLOAD_DISABLE;
}
public static void setPdfDownloadDisableValue(String pdfDownloadDisable) {
PDF_DOWNLOAD_DISABLE = pdfDownloadDisable;
}
@Value("${pdf.download.disable:true}")
public void setPdfDownloadDisable(String pdfDownloadDisable) {
PDF_DOWNLOAD_DISABLE = pdfDownloadDisable;
}
} }
...@@ -44,6 +44,7 @@ public class ConfigRefreshComponent { ...@@ -44,6 +44,7 @@ public class ConfigRefreshComponent {
String configFilePath = OfficeUtils.getCustomizedConfigPath(); String configFilePath = OfficeUtils.getCustomizedConfigPath();
String baseUrl; String baseUrl;
String trustHost; String trustHost;
String pdfDownloadDisable;
while (true) { while (true) {
FileReader fileReader = new FileReader(configFilePath); FileReader fileReader = new FileReader(configFilePath);
BufferedReader bufferedReader = new BufferedReader(fileReader); BufferedReader bufferedReader = new BufferedReader(fileReader);
...@@ -60,6 +61,7 @@ public class ConfigRefreshComponent { ...@@ -60,6 +61,7 @@ public class ConfigRefreshComponent {
mediaArray = media.split(","); mediaArray = media.split(",");
baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL); baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL);
trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST); trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST);
pdfDownloadDisable = properties.getProperty("pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE);
ConfigConstants.setCacheEnabled(cacheEnabled); ConfigConstants.setCacheEnabled(cacheEnabled);
ConfigConstants.setSimText(textArray); ConfigConstants.setSimText(textArray);
ConfigConstants.setMedia(mediaArray); ConfigConstants.setMedia(mediaArray);
...@@ -69,6 +71,7 @@ public class ConfigRefreshComponent { ...@@ -69,6 +71,7 @@ public class ConfigRefreshComponent {
ConfigConstants.setFtpControlEncoding(ftpControlEncoding); ConfigConstants.setFtpControlEncoding(ftpControlEncoding);
ConfigConstants.setBaseUrl(baseUrl); ConfigConstants.setBaseUrl(baseUrl);
ConfigConstants.setTrustHost(trustHost); ConfigConstants.setTrustHost(trustHost);
ConfigConstants.setPdfDownloadDisableValue(pdfDownloadDisable);
setWatermarkConfig(properties); setWatermarkConfig(properties);
bufferedReader.close(); bufferedReader.close();
fileReader.close(); fileReader.close();
......
package cn.keking.web.controller; package cn.keking.web.controller;
import cn.keking.config.ConfigConstants;
import cn.keking.hutool.URLUtil; import cn.keking.hutool.URLUtil;
import cn.keking.model.FileAttribute; import cn.keking.model.FileAttribute;
import cn.keking.service.FilePreview; import cn.keking.service.FilePreview;
...@@ -51,6 +52,7 @@ public class OnlinePreviewController { ...@@ -51,6 +52,7 @@ public class OnlinePreviewController {
public String onlinePreview(String url, Model model, HttpServletRequest req) { public String onlinePreview(String url, Model model, HttpServletRequest req) {
FileAttribute fileAttribute = fileUtils.getFileAttribute(url); FileAttribute fileAttribute = fileUtils.getFileAttribute(url);
req.setAttribute("fileKey", req.getParameter("fileKey")); req.setAttribute("fileKey", req.getParameter("fileKey"));
model.addAttribute("pdfDownloadDisable", ConfigConstants.getPdfDownloadDisable());
model.addAttribute("officePreviewType", req.getParameter("officePreviewType")); model.addAttribute("officePreviewType", req.getParameter("officePreviewType"));
FilePreview filePreview = previewFactory.get(fileAttribute); FilePreview filePreview = previewFactory.get(fileAttribute);
logger.info("预览文件url:{},previewType:{}", url, fileAttribute.getType()); logger.info("预览文件url:{},previewType:{}", url, fileAttribute.getType());
......
...@@ -1932,10 +1932,12 @@ function webViewerInitialized() { ...@@ -1932,10 +1932,12 @@ function webViewerInitialized() {
var appConfig = PDFViewerApplication.appConfig; var appConfig = PDFViewerApplication.appConfig;
var file = void 0; var file = void 0;
var base = void 0; var base = void 0;
var disableDownload = void 0;
var queryString = document.location.search.substring(1); var queryString = document.location.search.substring(1);
var params = (0, _ui_utils.parseQueryString)(queryString); var params = (0, _ui_utils.parseQueryString)(queryString);
file = 'file' in params ? params.file : appConfig.defaultUrl; file = 'file' in params ? params.file : appConfig.defaultUrl;
base = 'base' in params ? params.base : appConfig.defaultUrl; base = 'base' in params ? params.base : appConfig.defaultUrl;
disableDownload = 'disabledownload' in params ? params.disabledownload : 'false';
file = validateFileURL(file,base); file = validateFileURL(file,base);
var waitForBeforeOpening = []; var waitForBeforeOpening = [];
var fileInput = document.createElement('input'); var fileInput = document.createElement('input');
...@@ -2036,6 +2038,9 @@ function webViewerInitialized() { ...@@ -2036,6 +2038,9 @@ function webViewerInitialized() {
PDFViewerApplication.error(msg, reason); PDFViewerApplication.error(msg, reason);
}); });
}); });
if ('true' === disableDownload) {
document.getElementById("download").style.display='none';
}
} }
var webViewerOpenFileViaURL = void 0; var webViewerOpenFileViaURL = void 0;
{ {
......
...@@ -26,11 +26,10 @@ ...@@ -26,11 +26,10 @@
<img src="images/jpg.svg" width="63" height="63" style="position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/> <img src="images/jpg.svg" width="63" height="63" style="position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>
</body> </body>
<script src="js/watermark.js" type="text/javascript"></script> <script src="js/watermark.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?base=${baseUrl}&file="+encodeURIComponent('${finalUrl}'); document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?base=${baseUrl}&file="+encodeURIComponent('${finalUrl}')+"&disabledownload=${pdfDownloadDisable}";
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight-10; document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight-10;
/** /**
* 页面变化调整高度 * 页面变化调整高度
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment