Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
梁杰芳
slm-fileview
Commits
a535ebfe
Commit
a535ebfe
authored
May 14, 2020
by
陈精华
Committed by
kl
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新功能点:新增配置是否可以下载转换完成的pdf文件
parent
3e80590a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
2 deletions
+30
-2
application.properties
jodconverter-web/src/main/config/application.properties
+3
-0
ConfigConstants.java
...r-web/src/main/java/cn/keking/config/ConfigConstants.java
+16
-0
ConfigRefreshComponent.java
...rc/main/java/cn/keking/config/ConfigRefreshComponent.java
+3
-0
OnlinePreviewController.java
...ava/cn/keking/web/controller/OnlinePreviewController.java
+2
-0
viewer.js
...nverter-web/src/main/resources/static/pdfjs/web/viewer.js
+5
-0
pdf.ftl
jodconverter-web/src/main/resources/web/pdf.ftl
+1
-2
No files found.
jodconverter-web/src/main/config/application.properties
View file @
a535ebfe
...
...
@@ -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}
#office类型文档(word ppt)样式,默认为图片(image),可配置为pdf(预览时也有按钮切换)
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.username
=
${KK_FTP_USERNAME:ftpuser}
...
...
@@ -82,3 +84,4 @@ watermark.width = ${WATERMARK_WIDTH:180}
watermark.height
=
${WATERMARK_HEIGHT:80}
#水印倾斜度数,要求设置在大于等于0,小于90
watermark.angle
=
${WATERMARK_ANGLE:10}
jodconverter-web/src/main/java/cn/keking/config/ConfigConstants.java
View file @
a535ebfe
...
...
@@ -27,6 +27,7 @@ public class ConfigConstants {
private
static
String
BASE_URL
;
private
static
String
FILE_DIR
=
OfficeUtils
.
getHomePath
()
+
File
.
separator
+
"file"
+
File
.
separator
;
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_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 {
public
static
final
String
DEFAULT_BASE_URL
=
"default"
;
public
static
final
String
DEFAULT_FILE_DIR_VALUE
=
"default"
;
public
static
final
String
DEFAULT_TRUST_HOST
=
"default"
;
public
static
final
String
DEFAULT_PDF_DOWNLOAD_DISABLE
=
"true"
;
public
static
Boolean
isCacheEnabled
()
{
return
CACHE_ENABLED
;
...
...
@@ -141,4 +143,18 @@ public class ConfigConstants {
private
static
void
setTrustHostSet
(
CopyOnWriteArraySet
<
String
>
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
;
}
}
jodconverter-web/src/main/java/cn/keking/config/ConfigRefreshComponent.java
View file @
a535ebfe
...
...
@@ -44,6 +44,7 @@ public class ConfigRefreshComponent {
String
configFilePath
=
OfficeUtils
.
getCustomizedConfigPath
();
String
baseUrl
;
String
trustHost
;
String
pdfDownloadDisable
;
while
(
true
)
{
FileReader
fileReader
=
new
FileReader
(
configFilePath
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
fileReader
);
...
...
@@ -60,6 +61,7 @@ public class ConfigRefreshComponent {
mediaArray
=
media
.
split
(
","
);
baseUrl
=
properties
.
getProperty
(
"base.url"
,
ConfigConstants
.
DEFAULT_BASE_URL
);
trustHost
=
properties
.
getProperty
(
"trust.host"
,
ConfigConstants
.
DEFAULT_TRUST_HOST
);
pdfDownloadDisable
=
properties
.
getProperty
(
"pdf.download.disable"
,
ConfigConstants
.
DEFAULT_PDF_DOWNLOAD_DISABLE
);
ConfigConstants
.
setCacheEnabled
(
cacheEnabled
);
ConfigConstants
.
setSimText
(
textArray
);
ConfigConstants
.
setMedia
(
mediaArray
);
...
...
@@ -69,6 +71,7 @@ public class ConfigRefreshComponent {
ConfigConstants
.
setFtpControlEncoding
(
ftpControlEncoding
);
ConfigConstants
.
setBaseUrl
(
baseUrl
);
ConfigConstants
.
setTrustHost
(
trustHost
);
ConfigConstants
.
setPdfDownloadDisableValue
(
pdfDownloadDisable
);
setWatermarkConfig
(
properties
);
bufferedReader
.
close
();
fileReader
.
close
();
...
...
jodconverter-web/src/main/java/cn/keking/web/controller/OnlinePreviewController.java
View file @
a535ebfe
package
cn
.
keking
.
web
.
controller
;
import
cn.keking.config.ConfigConstants
;
import
cn.keking.hutool.URLUtil
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.service.FilePreview
;
...
...
@@ -51,6 +52,7 @@ public class OnlinePreviewController {
public
String
onlinePreview
(
String
url
,
Model
model
,
HttpServletRequest
req
)
{
FileAttribute
fileAttribute
=
fileUtils
.
getFileAttribute
(
url
);
req
.
setAttribute
(
"fileKey"
,
req
.
getParameter
(
"fileKey"
));
model
.
addAttribute
(
"pdfDownloadDisable"
,
ConfigConstants
.
getPdfDownloadDisable
());
model
.
addAttribute
(
"officePreviewType"
,
req
.
getParameter
(
"officePreviewType"
));
FilePreview
filePreview
=
previewFactory
.
get
(
fileAttribute
);
logger
.
info
(
"预览文件url:{},previewType:{}"
,
url
,
fileAttribute
.
getType
());
...
...
jodconverter-web/src/main/resources/static/pdfjs/web/viewer.js
View file @
a535ebfe
...
...
@@ -1932,10 +1932,12 @@ function webViewerInitialized() {
var
appConfig
=
PDFViewerApplication
.
appConfig
;
var
file
=
void
0
;
var
base
=
void
0
;
var
disableDownload
=
void
0
;
var
queryString
=
document
.
location
.
search
.
substring
(
1
);
var
params
=
(
0
,
_ui_utils
.
parseQueryString
)(
queryString
);
file
=
'file'
in
params
?
params
.
file
:
appConfig
.
defaultUrl
;
base
=
'base'
in
params
?
params
.
base
:
appConfig
.
defaultUrl
;
disableDownload
=
'disabledownload'
in
params
?
params
.
disabledownload
:
'false'
;
file
=
validateFileURL
(
file
,
base
);
var
waitForBeforeOpening
=
[];
var
fileInput
=
document
.
createElement
(
'input'
);
...
...
@@ -2036,6 +2038,9 @@ function webViewerInitialized() {
PDFViewerApplication
.
error
(
msg
,
reason
);
});
});
if
(
'true'
===
disableDownload
)
{
document
.
getElementById
(
"download"
).
style
.
display
=
'none'
;
}
}
var
webViewerOpenFileViaURL
=
void
0
;
{
...
...
jodconverter-web/src/main/resources/web/pdf.ftl
View file @
a535ebfe
...
...
@@ -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()"
/>
</body>
<script
src=
"js/watermark.js"
type=
"text/javascript"
></script>
<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
;
/**
* 页面变化调整高度
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment