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
0f4f1d58
Commit
0f4f1d58
authored
Dec 26, 2020
by
chenkailing
Committed by
kl
Dec 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、抽象整理FileType的获取逻辑
2、合理设置预览消费队列的线程数
parent
37c37868
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
133 additions
and
168 deletions
+133
-168
freemarker_implicit.ftl
jodconverter-web/src/main/config/freemarker_implicit.ftl
+1
-0
FileType.java
jodconverter-web/src/main/java/cn/keking/model/FileType.java
+39
-2
FileConvertQueueTask.java
...src/main/java/cn/keking/service/FileConvertQueueTask.java
+9
-18
FilePreviewCommonService.java
...main/java/cn/keking/service/FilePreviewCommonService.java
+6
-70
CadFilePreviewImpl.java
.../main/java/cn/keking/service/impl/CadFilePreviewImpl.java
+6
-6
CompressFilePreviewImpl.java
.../java/cn/keking/service/impl/CompressFilePreviewImpl.java
+7
-7
MediaFilePreviewImpl.java
...ain/java/cn/keking/service/impl/MediaFilePreviewImpl.java
+5
-5
OfficeFilePreviewImpl.java
...in/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
+7
-7
PdfFilePreviewImpl.java
.../main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
+9
-9
PictureFilePreviewImpl.java
...n/java/cn/keking/service/impl/PictureFilePreviewImpl.java
+6
-6
DownloadUtils.java
...rter-web/src/main/java/cn/keking/utils/DownloadUtils.java
+7
-6
PdfUtils.java
jodconverter-web/src/main/java/cn/keking/utils/PdfUtils.java
+6
-5
ZipReader.java
...onverter-web/src/main/java/cn/keking/utils/ZipReader.java
+14
-13
OnlinePreviewController.java
...ava/cn/keking/web/controller/OnlinePreviewController.java
+8
-11
picture.ftl
jodconverter-web/src/main/resources/web/picture.ftl
+1
-1
txt.ftl
jodconverter-web/src/main/resources/web/txt.ftl
+2
-2
No files found.
jodconverter-web/src/main/config/freemarker_implicit.ftl
View file @
0f4f1d58
[#ftl]
[#-- @implicitly included --]
[#-- @ftlvariable name="imgUrls" type="String" --]
[#-- @ftlvariable name="textData" type="java.lang.String" --]
[#-- @ftlvariable name="xmlContent" type="java.lang.String" --]
[#-- @ftlvariable name="textContent" type="java.lang.String" --]
...
...
jodconverter-web/src/main/java/cn/keking/model/FileType.java
View file @
0f4f1d58
package
cn
.
keking
.
model
;
import
cn.keking.config.ConfigConstants
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by kl on 2018/1/17.
* Content :文件类型,文本,office,压缩包等等
...
...
@@ -16,11 +21,43 @@ public enum FileType {
xml
(
"xmlFilePreviewImpl"
),
cad
(
"cadFilePreviewImpl"
);
private
static
final
String
[]
OFFICE_TYPES
=
{
"docx"
,
"doc"
,
"xls"
,
"xlsx"
,
"ppt"
,
"pptx"
};
private
static
final
String
[]
PICTURE_TYPES
=
{
"jpg"
,
"jpeg"
,
"png"
,
"gif"
,
"bmp"
,
"ico"
,
"RAW"
};
private
static
final
String
[]
ARCHIVE_TYPES
=
{
"rar"
,
"zip"
,
"jar"
,
"7-zip"
,
"tar"
,
"gzip"
,
"7z"
};
private
static
final
String
[]
SIMTEXT_TYPES
=
ConfigConstants
.
getSimText
();
private
static
final
String
[]
MEDIA_TYPES
=
ConfigConstants
.
getMedia
();
private
static
final
Map
<
String
,
FileType
>
FILE_TYPE_MAPPER
=
new
HashMap
<>();
static
{
for
(
String
office
:
OFFICE_TYPES
)
{
FILE_TYPE_MAPPER
.
put
(
office
,
FileType
.
office
);
}
for
(
String
picture
:
PICTURE_TYPES
)
{
FILE_TYPE_MAPPER
.
put
(
picture
,
FileType
.
picture
);
}
for
(
String
archive
:
ARCHIVE_TYPES
)
{
FILE_TYPE_MAPPER
.
put
(
archive
,
FileType
.
compress
);
}
for
(
String
text
:
SIMTEXT_TYPES
)
{
FILE_TYPE_MAPPER
.
put
(
text
,
FileType
.
simText
);
}
for
(
String
media
:
MEDIA_TYPES
)
{
FILE_TYPE_MAPPER
.
put
(
media
,
FileType
.
media
);
}
FILE_TYPE_MAPPER
.
put
(
"md"
,
FileType
.
markdown
);
FILE_TYPE_MAPPER
.
put
(
"xml"
,
FileType
.
xml
);
FILE_TYPE_MAPPER
.
put
(
"pdf"
,
FileType
.
pdf
);
FILE_TYPE_MAPPER
.
put
(
"dwg"
,
FileType
.
cad
);
}
public
static
FileType
to
(
String
fileType
){
return
FILE_TYPE_MAPPER
.
getOrDefault
(
fileType
,
other
);
}
private
final
String
instanceName
;
FileType
(
String
instanceName
){
this
.
instanceName
=
instanceName
;
FileType
(
String
instanceName
)
{
this
.
instanceName
=
instanceName
;
}
public
String
getInstanceName
()
{
...
...
jodconverter-web/src/main/java/cn/keking/service/FileConvertQueueTask.java
View file @
0f4f1d58
...
...
@@ -3,7 +3,6 @@ package cn.keking.service;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.FileType
;
import
cn.keking.service.cache.CacheService
;
import
cn.keking.utils.FileUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
...
...
@@ -20,44 +19,36 @@ import java.util.concurrent.Executors;
public
class
FileConvertQueueTask
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
final
FilePreviewFactory
previewFactory
;
private
final
CacheService
cacheService
;
private
final
FilePreviewCommonService
filePreviewCommonService
;
private
final
FileUtils
fileUtils
;
public
FileConvertQueueTask
(
FilePreviewFactory
previewFactory
,
CacheService
cacheService
,
FileUtils
fileUtils
)
{
public
FileConvertQueueTask
(
FilePreviewFactory
previewFactory
,
CacheService
cacheService
,
FilePreviewCommonService
filePreviewCommonService
)
{
this
.
previewFactory
=
previewFactory
;
this
.
cacheService
=
cacheService
;
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
}
@PostConstruct
public
void
startTask
(){
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
3
);
executorService
.
submit
(
new
ConvertTask
(
previewFactory
,
cacheService
,
file
Utils
));
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
1
);
executorService
.
submit
(
new
ConvertTask
(
previewFactory
,
cacheService
,
file
PreviewCommonService
));
logger
.
info
(
"队列处理文件转换任务启动完成 "
);
}
static
class
ConvertTask
implements
Runnable
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ConvertTask
.
class
);
private
final
FilePreviewFactory
previewFactory
;
private
final
CacheService
cacheService
;
private
final
FileUtils
fileUtils
;
private
final
FilePreviewCommonService
filePreviewCommonService
;
public
ConvertTask
(
FilePreviewFactory
previewFactory
,
CacheService
cacheService
,
File
Utils
fileUtils
)
{
File
PreviewCommonService
filePreviewCommonService
)
{
this
.
previewFactory
=
previewFactory
;
this
.
cacheService
=
cacheService
;
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
}
@Override
...
...
@@ -67,7 +58,7 @@ public class FileConvertQueueTask {
try
{
url
=
cacheService
.
takeQueueTask
();
if
(
url
!=
null
){
FileAttribute
fileAttribute
=
file
Utils
.
getFileAttribute
(
url
,
null
);
FileAttribute
fileAttribute
=
file
PreviewCommonService
.
getFileAttribute
(
url
,
null
);
FileType
fileType
=
fileAttribute
.
getType
();
logger
.
info
(
"正在处理预览转换任务,url:{},预览类型:{}"
,
url
,
fileType
);
if
(
fileType
.
equals
(
FileType
.
compress
)
||
fileType
.
equals
(
FileType
.
office
)
||
fileType
.
equals
(
FileType
.
cad
))
{
...
...
jodconverter-web/src/main/java/cn/keking/
utils/FileUtils
.java
→
jodconverter-web/src/main/java/cn/keking/
service/FilePreviewCommonService
.java
View file @
0f4f1d58
package
cn
.
keking
.
utils
;
package
cn
.
keking
.
service
;
import
cn.keking.config.ConfigConstants
;
import
cn.keking.model.FileAttribute
;
...
...
@@ -18,14 +18,14 @@ import java.util.*;
* @date 2017/11/13
*/
@Component
public
class
File
Utils
{
public
class
File
PreviewCommonService
{
private
static
final
String
DEFAULT_CONVERTER_CHARSET
=
System
.
getProperty
(
"sun.jnu.encoding"
);
private
final
String
fileDir
=
ConfigConstants
.
getFileDir
();
private
final
CacheService
cacheService
;
public
File
Utils
(
CacheService
cacheService
)
{
public
File
PreviewCommonService
(
CacheService
cacheService
)
{
this
.
cacheService
=
cacheService
;
}
...
...
@@ -60,41 +60,12 @@ public class FileUtils {
public
FileType
typeFromUrl
(
String
url
)
{
String
nonPramStr
=
url
.
substring
(
0
,
url
.
contains
(
"?"
)
?
url
.
indexOf
(
"?"
)
:
url
.
length
());
String
fileName
=
nonPramStr
.
substring
(
nonPramStr
.
lastIndexOf
(
"/"
)
+
1
);
return
typeFromFileName
(
fileName
);
return
t
his
.
t
ypeFromFileName
(
fileName
);
}
private
FileType
typeFromFileName
(
String
fileName
)
{
String
[]
simText
=
ConfigConstants
.
getSimText
();
String
[]
media
=
ConfigConstants
.
getMedia
();
String
fileType
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)
+
1
);
if
(
listPictureTypes
().
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
picture
;
}
if
(
listArchiveTypes
().
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
compress
;
}
if
(
listOfficeTypes
().
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
office
;
}
if
(
"md"
.
equalsIgnoreCase
(
fileType
))
{
return
FileType
.
markdown
;
}
if
(
"xml"
.
equalsIgnoreCase
(
fileType
))
{
return
FileType
.
xml
;
}
if
(
Arrays
.
asList
(
simText
).
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
simText
;
}
if
(
Arrays
.
asList
(
media
).
contains
(
fileType
.
toLowerCase
()))
{
return
FileType
.
media
;
}
if
(
"pdf"
.
equalsIgnoreCase
(
fileType
))
{
return
FileType
.
pdf
;
}
if
(
"dwg"
.
equalsIgnoreCase
(
fileType
))
{
return
FileType
.
cad
;
}
return
FileType
.
other
;
return
FileType
.
to
(
fileType
);
}
/**
...
...
@@ -120,41 +91,6 @@ public class FileUtils {
return
path
.
substring
(
path
.
lastIndexOf
(
File
.
separator
)
+
1
);
}
public
List
<
String
>
listPictureTypes
()
{
List
<
String
>
list
=
new
LinkedList
<>();
list
.
add
(
"jpg"
);
list
.
add
(
"jpeg"
);
list
.
add
(
"png"
);
list
.
add
(
"gif"
);
list
.
add
(
"bmp"
);
list
.
add
(
"ico"
);
list
.
add
(
"RAW"
);
return
list
;
}
public
List
<
String
>
listArchiveTypes
()
{
List
<
String
>
list
=
new
LinkedList
<>();
list
.
add
(
"rar"
);
list
.
add
(
"zip"
);
list
.
add
(
"jar"
);
list
.
add
(
"7-zip"
);
list
.
add
(
"tar"
);
list
.
add
(
"gzip"
);
list
.
add
(
"7z"
);
return
list
;
}
public
List
<
String
>
listOfficeTypes
()
{
List
<
String
>
list
=
new
LinkedList
<>();
list
.
add
(
"docx"
);
list
.
add
(
"doc"
);
list
.
add
(
"xls"
);
list
.
add
(
"xlsx"
);
list
.
add
(
"ppt"
);
list
.
add
(
"pptx"
);
return
list
;
}
/**
* 获取相对路径
*
...
...
@@ -341,7 +277,7 @@ public class FileUtils {
String
fullFileName
=
this
.
getUrlParameterReg
(
url
,
"fullfilename"
);
if
(
StringUtils
.
hasText
(
fullFileName
))
{
fileName
=
fullFileName
;
type
=
typeFromFileName
(
fullFileName
);
type
=
t
his
.
t
ypeFromFileName
(
fullFileName
);
suffix
=
suffixFromFileName
(
fullFileName
);
}
else
{
fileName
=
getFileNameFromURL
(
url
);
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/CadFilePreviewImpl.java
View file @
0f4f1d58
...
...
@@ -6,7 +6,7 @@ import cn.keking.model.ReturnResponse;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.CadUtils
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
cn.keking.utils.PdfUtils
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
org.springframework.stereotype.Service
;
...
...
@@ -22,7 +22,7 @@ import static cn.keking.service.impl.OfficeFilePreviewImpl.getPreviewType;
@Service
public
class
CadFilePreviewImpl
implements
FilePreview
{
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
DownloadUtils
downloadUtils
;
...
...
@@ -30,11 +30,11 @@ public class CadFilePreviewImpl implements FilePreview {
private
final
PdfUtils
pdfUtils
;
public
CadFilePreviewImpl
(
File
Utils
fileUtils
,
public
CadFilePreviewImpl
(
File
PreviewCommonService
filePreviewCommonService
,
DownloadUtils
downloadUtils
,
CadUtils
cadUtils
,
PdfUtils
pdfUtils
)
{
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
this
.
downloadUtils
=
downloadUtils
;
this
.
cadUtils
=
cadUtils
;
this
.
pdfUtils
=
pdfUtils
;
...
...
@@ -56,7 +56,7 @@ public class CadFilePreviewImpl implements FilePreview {
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
"pdf"
;
String
outFilePath
=
FILE_DIR
+
pdfName
;
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
if
(!
file
Utils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
file
PreviewCommonService
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
String
filePath
;
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
null
);
if
(
0
!=
response
.
getCode
())
{
...
...
@@ -74,7 +74,7 @@ public class CadFilePreviewImpl implements FilePreview {
}
if
(
ConfigConstants
.
isCacheEnabled
())
{
// 加入缓存
file
Utils
.
addConvertedFile
(
pdfName
,
fileUtils
.
getRelativePath
(
outFilePath
));
file
PreviewCommonService
.
addConvertedFile
(
pdfName
,
filePreviewCommonService
.
getRelativePath
(
outFilePath
));
}
}
}
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/CompressFilePreviewImpl.java
View file @
0f4f1d58
...
...
@@ -5,7 +5,7 @@ import cn.keking.model.FileAttribute;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
cn.keking.utils.ZipReader
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
...
...
@@ -18,16 +18,16 @@ import org.springframework.util.StringUtils;
@Service
public
class
CompressFilePreviewImpl
implements
FilePreview
{
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
DownloadUtils
downloadUtils
;
private
final
ZipReader
zipReader
;
public
CompressFilePreviewImpl
(
File
Utils
fileUtils
,
public
CompressFilePreviewImpl
(
File
PreviewCommonService
filePreviewCommonService
,
DownloadUtils
downloadUtils
,
ZipReader
zipReader
)
{
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
this
.
downloadUtils
=
downloadUtils
;
this
.
zipReader
=
zipReader
;
}
...
...
@@ -38,7 +38,7 @@ public class CompressFilePreviewImpl implements FilePreview {
String
suffix
=
fileAttribute
.
getSuffix
();
String
fileTree
=
null
;
// 判断文件名是否存在(redis缓存读取)
if
(!
StringUtils
.
hasText
(
file
Utils
.
getConvertedFile
(
fileName
))
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
StringUtils
.
hasText
(
file
PreviewCommonService
.
getConvertedFile
(
fileName
))
||
!
ConfigConstants
.
isCacheEnabled
())
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
fileName
);
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
suffix
);
...
...
@@ -54,10 +54,10 @@ public class CompressFilePreviewImpl implements FilePreview {
fileTree
=
zipReader
.
read7zFile
(
filePath
,
fileName
);
}
if
(
fileTree
!=
null
&&
!
"null"
.
equals
(
fileTree
)
&&
ConfigConstants
.
isCacheEnabled
())
{
file
Utils
.
addConvertedFile
(
fileName
,
fileTree
);
file
PreviewCommonService
.
addConvertedFile
(
fileName
,
fileTree
);
}
}
else
{
fileTree
=
file
Utils
.
getConvertedFile
(
fileName
);
fileTree
=
file
PreviewCommonService
.
getConvertedFile
(
fileName
);
}
if
(
fileTree
!=
null
&&
!
"null"
.
equals
(
fileTree
))
{
model
.
addAttribute
(
"fileTree"
,
fileTree
);
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/MediaFilePreviewImpl.java
View file @
0f4f1d58
...
...
@@ -4,7 +4,7 @@ import cn.keking.model.FileAttribute;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
...
...
@@ -19,12 +19,12 @@ public class MediaFilePreviewImpl implements FilePreview {
private
final
DownloadUtils
downloadUtils
;
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
public
MediaFilePreviewImpl
(
DownloadUtils
downloadUtils
,
File
Utils
fileUtils
)
{
File
PreviewCommonService
filePreviewCommonService
)
{
this
.
downloadUtils
=
downloadUtils
;
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
}
@Override
...
...
@@ -37,7 +37,7 @@ public class MediaFilePreviewImpl implements FilePreview {
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
}
else
{
model
.
addAttribute
(
"mediaUrl"
,
BaseUrlFilter
.
getBaseUrl
()
+
file
Utils
.
getRelativePath
(
response
.
getContent
()));
model
.
addAttribute
(
"mediaUrl"
,
BaseUrlFilter
.
getBaseUrl
()
+
file
PreviewCommonService
.
getRelativePath
(
response
.
getContent
()));
}
}
else
{
model
.
addAttribute
(
"mediaUrl"
,
url
);
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
View file @
0f4f1d58
...
...
@@ -5,7 +5,7 @@ import cn.keking.model.FileAttribute;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
cn.keking.service.OfficeToPdfService
;
import
cn.keking.utils.PdfUtils
;
import
cn.keking.web.filter.BaseUrlFilter
;
...
...
@@ -22,13 +22,13 @@ import java.util.List;
@Service
public
class
OfficeFilePreviewImpl
implements
FilePreview
{
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
PdfUtils
pdfUtils
;
private
final
DownloadUtils
downloadUtils
;
private
final
OfficeToPdfService
officeToPdfService
;
public
OfficeFilePreviewImpl
(
File
Utils
fileUtils
,
PdfUtils
pdfUtils
,
DownloadUtils
downloadUtils
,
OfficeToPdfService
officeToPdfService
)
{
this
.
file
Utils
=
fileUtils
;
public
OfficeFilePreviewImpl
(
File
PreviewCommonService
filePreviewCommonService
,
PdfUtils
pdfUtils
,
DownloadUtils
downloadUtils
,
OfficeToPdfService
officeToPdfService
)
{
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
this
.
pdfUtils
=
pdfUtils
;
this
.
downloadUtils
=
downloadUtils
;
this
.
officeToPdfService
=
officeToPdfService
;
...
...
@@ -49,7 +49,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
(
isHtml
?
"html"
:
"pdf"
);
String
outFilePath
=
FILE_DIR
+
pdfName
;
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
if
(!
file
Utils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
file
PreviewCommonService
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
String
filePath
;
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
null
);
if
(
0
!=
response
.
getCode
())
{
...
...
@@ -62,11 +62,11 @@ public class OfficeFilePreviewImpl implements FilePreview {
officeToPdfService
.
openOfficeToPDF
(
filePath
,
outFilePath
);
if
(
isHtml
)
{
// 对转换后的文件进行操作(改变编码方式)
file
Utils
.
doActionConvertedFile
(
outFilePath
);
file
PreviewCommonService
.
doActionConvertedFile
(
outFilePath
);
}
if
(
ConfigConstants
.
isCacheEnabled
())
{
// 加入缓存
file
Utils
.
addConvertedFile
(
pdfName
,
fileUtils
.
getRelativePath
(
outFilePath
));
file
PreviewCommonService
.
addConvertedFile
(
pdfName
,
filePreviewCommonService
.
getRelativePath
(
outFilePath
));
}
}
}
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
View file @
0f4f1d58
...
...
@@ -5,7 +5,7 @@ import cn.keking.model.FileAttribute;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
cn.keking.utils.PdfUtils
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
org.springframework.stereotype.Service
;
...
...
@@ -20,7 +20,7 @@ import java.util.List;
@Service
public
class
PdfFilePreviewImpl
implements
FilePreview
{
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
PdfUtils
pdfUtils
;
...
...
@@ -28,10 +28,10 @@ public class PdfFilePreviewImpl implements FilePreview {
private
static
final
String
FILE_DIR
=
ConfigConstants
.
getFileDir
();
public
PdfFilePreviewImpl
(
File
Utils
fileUtils
,
public
PdfFilePreviewImpl
(
File
PreviewCommonService
filePreviewCommonService
,
PdfUtils
pdfUtils
,
DownloadUtils
downloadUtils
)
{
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
this
.
pdfUtils
=
pdfUtils
;
this
.
downloadUtils
=
downloadUtils
;
}
...
...
@@ -46,7 +46,7 @@ public class PdfFilePreviewImpl implements FilePreview {
String
outFilePath
=
FILE_DIR
+
pdfName
;
if
(
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_IMAGE
.
equals
(
officePreviewType
)
||
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_ALL_IMAGES
.
equals
(
officePreviewType
))
{
//当文件不存在时,就去下载
if
(!
file
Utils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
file
PreviewCommonService
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
fileName
);
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
suffix
);
...
...
@@ -56,7 +56,7 @@ public class PdfFilePreviewImpl implements FilePreview {
outFilePath
=
response
.
getContent
();
if
(
ConfigConstants
.
isCacheEnabled
())
{
// 加入缓存
file
Utils
.
addConvertedFile
(
pdfName
,
fileUtils
.
getRelativePath
(
outFilePath
));
file
PreviewCommonService
.
addConvertedFile
(
pdfName
,
filePreviewCommonService
.
getRelativePath
(
outFilePath
));
}
}
List
<
String
>
imageUrls
=
pdfUtils
.
pdf2jpg
(
outFilePath
,
pdfName
,
baseUrl
);
...
...
@@ -75,17 +75,17 @@ public class PdfFilePreviewImpl implements FilePreview {
}
else
{
// 不是http开头,浏览器不能直接访问,需下载到本地
if
(
url
!=
null
&&
!
url
.
toLowerCase
().
startsWith
(
"http"
))
{
if
(!
file
Utils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
file
PreviewCommonService
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
ReturnResponse
<
String
>
response
=
downloadUtils
.
downLoad
(
fileAttribute
,
pdfName
);
if
(
0
!=
response
.
getCode
())
{
model
.
addAttribute
(
"fileType"
,
suffix
);
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
}
model
.
addAttribute
(
"pdfUrl"
,
file
Utils
.
getRelativePath
(
response
.
getContent
()));
model
.
addAttribute
(
"pdfUrl"
,
file
PreviewCommonService
.
getRelativePath
(
response
.
getContent
()));
if
(
ConfigConstants
.
isCacheEnabled
())
{
// 加入缓存
file
Utils
.
addConvertedFile
(
pdfName
,
fileUtils
.
getRelativePath
(
outFilePath
));
file
PreviewCommonService
.
addConvertedFile
(
pdfName
,
filePreviewCommonService
.
getRelativePath
(
outFilePath
));
}
}
else
{
model
.
addAttribute
(
"pdfUrl"
,
pdfName
);
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java
View file @
0f4f1d58
...
...
@@ -4,7 +4,7 @@ import cn.keking.model.FileAttribute;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.Model
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -18,13 +18,13 @@ import java.util.List;
@Service
public
class
PictureFilePreviewImpl
implements
FilePreview
{
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
DownloadUtils
downloadUtils
;
public
PictureFilePreviewImpl
(
File
Utils
fileUtils
,
public
PictureFilePreviewImpl
(
File
PreviewCommonService
filePreviewCommonService
,
DownloadUtils
downloadUtils
)
{
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
this
.
downloadUtils
=
downloadUtils
;
}
...
...
@@ -33,7 +33,7 @@ public class PictureFilePreviewImpl implements FilePreview {
List
<
String
>
imgUrls
=
new
ArrayList
<>();
imgUrls
.
add
(
url
);
String
fileKey
=
fileAttribute
.
getFileKey
();
List
<
String
>
zipImgUrls
=
file
Utils
.
getImgCache
(
fileKey
);
List
<
String
>
zipImgUrls
=
file
PreviewCommonService
.
getImgCache
(
fileKey
);
if
(!
CollectionUtils
.
isEmpty
(
zipImgUrls
))
{
imgUrls
.
addAll
(
zipImgUrls
);
}
...
...
@@ -45,7 +45,7 @@ public class PictureFilePreviewImpl implements FilePreview {
model
.
addAttribute
(
"msg"
,
response
.
getMsg
());
return
"fileNotSupported"
;
}
else
{
String
file
=
file
Utils
.
getRelativePath
(
response
.
getContent
());
String
file
=
file
PreviewCommonService
.
getRelativePath
(
response
.
getContent
());
imgUrls
.
clear
();
imgUrls
.
add
(
file
);
model
.
addAttribute
(
"imgurls"
,
imgUrls
);
...
...
jodconverter-web/src/main/java/cn/keking/utils/DownloadUtils.java
View file @
0f4f1d58
...
...
@@ -5,6 +5,7 @@ import cn.keking.hutool.URLUtil;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.FileType
;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreviewCommonService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
...
...
@@ -24,10 +25,10 @@ public class DownloadUtils {
private
final
String
fileDir
=
ConfigConstants
.
getFileDir
();
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
public
DownloadUtils
(
File
Utils
fileUtils
)
{
this
.
file
Utils
=
fileUtils
;
public
DownloadUtils
(
File
PreviewCommonService
filePreviewCommonService
)
{
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
}
private
static
final
String
URL_PARAM_FTP_USERNAME
=
"ftp.username"
;
...
...
@@ -61,9 +62,9 @@ public class DownloadUtils {
OutputStream
os
=
new
FileOutputStream
(
realPath
);
saveBytesToOutStream
(
bytes
,
os
);
}
else
if
(
url
.
getProtocol
()
!=
null
&&
"ftp"
.
equalsIgnoreCase
(
url
.
getProtocol
()))
{
String
ftpUsername
=
file
Utils
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_USERNAME
);
String
ftpPassword
=
file
Utils
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_PASSWORD
);
String
ftpControlEncoding
=
file
Utils
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_CONTROL_ENCODING
);
String
ftpUsername
=
file
PreviewCommonService
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_USERNAME
);
String
ftpPassword
=
file
PreviewCommonService
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_PASSWORD
);
String
ftpControlEncoding
=
file
PreviewCommonService
.
getUrlParameterReg
(
fileAttribute
.
getUrl
(),
URL_PARAM_FTP_CONTROL_ENCODING
);
FtpUtils
.
download
(
fileAttribute
.
getUrl
(),
realPath
,
ftpUsername
,
ftpPassword
,
ftpControlEncoding
);
}
else
{
response
.
setCode
(
1
);
...
...
jodconverter-web/src/main/java/cn/keking/utils/PdfUtils.java
View file @
0f4f1d58
package
cn
.
keking
.
utils
;
import
cn.keking.service.FilePreviewCommonService
;
import
org.apache.pdfbox.pdmodel.PDDocument
;
import
org.apache.pdfbox.rendering.ImageType
;
import
org.apache.pdfbox.rendering.PDFRenderer
;
...
...
@@ -22,18 +23,18 @@ public class PdfUtils {
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PdfUtils
.
class
);
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
@Value
(
"${server.tomcat.uri-encoding:UTF-8}"
)
private
String
uriEncoding
;
public
PdfUtils
(
File
Utils
fileUtils
)
{
this
.
file
Utils
=
fileUtils
;
public
PdfUtils
(
File
PreviewCommonService
filePreviewCommonService
)
{
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
}
public
List
<
String
>
pdf2jpg
(
String
pdfFilePath
,
String
pdfName
,
String
baseUrl
)
{
List
<
String
>
imageUrls
=
new
ArrayList
<>();
Integer
imageCount
=
file
Utils
.
getConvertedPdfImage
(
pdfFilePath
);
Integer
imageCount
=
file
PreviewCommonService
.
getConvertedPdfImage
(
pdfFilePath
);
String
imageFileSuffix
=
".jpg"
;
String
pdfFolder
=
pdfName
.
substring
(
0
,
pdfName
.
length
()
-
4
);
String
urlPrefix
=
null
;
...
...
@@ -69,7 +70,7 @@ public class PdfUtils {
imageUrls
.
add
(
urlPrefix
+
"/"
+
pageIndex
+
imageFileSuffix
);
}
doc
.
close
();
file
Utils
.
addConvertedPdfImage
(
pdfFilePath
,
pageCount
);
file
PreviewCommonService
.
addConvertedPdfImage
(
pdfFilePath
,
pageCount
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"Convert pdf to jpg exception, pdfFilePath:{}"
,
pdfFilePath
,
e
);
}
...
...
jodconverter-web/src/main/java/cn/keking/utils/ZipReader.java
View file @
0f4f1d58
...
...
@@ -2,6 +2,7 @@ package cn.keking.utils;
import
cn.keking.config.ConfigConstants
;
import
cn.keking.model.FileType
;
import
cn.keking.service.FilePreviewCommonService
;
import
cn.keking.web.filter.BaseUrlFilter
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -33,14 +34,14 @@ import java.util.regex.Pattern;
public
class
ZipReader
{
static
Pattern
pattern
=
Pattern
.
compile
(
"^\\d+"
);
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
String
fileDir
=
ConfigConstants
.
getFileDir
();
private
final
ExecutorService
executors
=
Executors
.
newFixedThreadPool
(
Runtime
.
getRuntime
().
availableProcessors
());
public
ZipReader
(
File
Utils
fileUtils
)
{
this
.
file
Utils
=
fileUtils
;
public
ZipReader
(
File
PreviewCommonService
filePreviewCommonService
)
{
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
}
public
String
readZipFile
(
String
filePath
,
String
fileKey
)
{
...
...
@@ -48,9 +49,9 @@ public class ZipReader {
Map
<
String
,
FileNode
>
appender
=
new
HashMap
<>();
List
<
String
>
imgUrls
=
new
LinkedList
<>();
String
baseUrl
=
BaseUrlFilter
.
getBaseUrl
();
String
archiveFileName
=
file
Utils
.
getFileNameFromPath
(
filePath
);
String
archiveFileName
=
file
PreviewCommonService
.
getFileNameFromPath
(
filePath
);
try
{
ZipFile
zipFile
=
new
ZipFile
(
filePath
,
file
Utils
.
getFileEncodeUTFGBK
(
filePath
));
ZipFile
zipFile
=
new
ZipFile
(
filePath
,
file
PreviewCommonService
.
getFileEncodeUTFGBK
(
filePath
));
Enumeration
<
ZipArchiveEntry
>
entries
=
zipFile
.
getEntries
();
// 排序
entries
=
sortZipEntries
(
entries
);
...
...
@@ -69,7 +70,7 @@ public class ZipReader {
}
String
parentName
=
getLast2FileName
(
fullName
,
archiveSeparator
,
archiveFileName
);
parentName
=
(
level
-
1
)
+
"_"
+
parentName
;
FileType
type
=
fileUtils
.
typeFromUrl
(
childName
);
FileType
type
=
filePreviewCommonService
.
typeFromUrl
(
childName
);
if
(
type
.
equals
(
FileType
.
picture
)){
//添加图片文件到图片列表
imgUrls
.
add
(
baseUrl
+
childName
);
}
...
...
@@ -79,7 +80,7 @@ public class ZipReader {
}
// 开启新的线程处理文件解压
executors
.
submit
(
new
ZipExtractorWorker
(
entriesToBeExtracted
,
zipFile
,
filePath
));
file
Utils
.
putImgCache
(
fileKey
,
imgUrls
);
file
PreviewCommonService
.
putImgCache
(
fileKey
,
imgUrls
);
return
new
ObjectMapper
().
writeValueAsString
(
appender
.
get
(
""
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -104,7 +105,7 @@ public class ZipReader {
Archive
archive
=
new
Archive
(
new
FileInputStream
(
new
File
(
filePath
)));
List
<
FileHeader
>
headers
=
archive
.
getFileHeaders
();
headers
=
sortedHeaders
(
headers
);
String
archiveFileName
=
file
Utils
.
getFileNameFromPath
(
filePath
);
String
archiveFileName
=
file
PreviewCommonService
.
getFileNameFromPath
(
filePath
);
List
<
Map
<
String
,
FileHeader
>>
headersToBeExtracted
=
new
ArrayList
<>();
for
(
FileHeader
header
:
headers
)
{
String
fullName
;
...
...
@@ -122,7 +123,7 @@ public class ZipReader {
headersToBeExtracted
.
add
(
Collections
.
singletonMap
(
childName
,
header
));
}
String
parentName
=
getLast2FileName
(
fullName
,
"\\"
,
archiveFileName
);
FileType
type
=
file
Utils
.
typeFromUrl
(
childName
);
FileType
type
=
file
PreviewCommonService
.
typeFromUrl
(
childName
);
if
(
type
.
equals
(
FileType
.
picture
)){
//添加图片文件到图片列表
imgUrls
.
add
(
baseUrl
+
childName
);
}
...
...
@@ -131,7 +132,7 @@ public class ZipReader {
appender
.
put
(
childName
,
node
);
}
executors
.
submit
(
new
RarExtractorWorker
(
headersToBeExtracted
,
archive
,
filePath
));
file
Utils
.
putImgCache
(
fileKey
,
imgUrls
);
file
PreviewCommonService
.
putImgCache
(
fileKey
,
imgUrls
);
return
new
ObjectMapper
().
writeValueAsString
(
appender
.
get
(
""
));
}
catch
(
RarException
|
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -144,7 +145,7 @@ public class ZipReader {
Map
<
String
,
FileNode
>
appender
=
new
HashMap
<>();
List
<
String
>
imgUrls
=
new
ArrayList
<>();
String
baseUrl
=
BaseUrlFilter
.
getBaseUrl
();
String
archiveFileName
=
file
Utils
.
getFileNameFromPath
(
filePath
);
String
archiveFileName
=
file
PreviewCommonService
.
getFileNameFromPath
(
filePath
);
try
{
SevenZFile
zipFile
=
new
SevenZFile
(
new
File
(
filePath
));
Iterable
<
SevenZArchiveEntry
>
entries
=
zipFile
.
getEntries
();
...
...
@@ -165,7 +166,7 @@ public class ZipReader {
}
String
parentName
=
getLast2FileName
(
fullName
,
archiveSeparator
,
archiveFileName
);
parentName
=
(
level
-
1
)
+
"_"
+
parentName
;
FileType
type
=
fileUtils
.
typeFromUrl
(
childName
);
FileType
type
=
filePreviewCommonService
.
typeFromUrl
(
childName
);
if
(
type
.
equals
(
FileType
.
picture
)){
//添加图片文件到图片列表
imgUrls
.
add
(
baseUrl
+
childName
);
}
...
...
@@ -175,7 +176,7 @@ public class ZipReader {
}
// 开启新的线程处理文件解压
executors
.
submit
(
new
SevenZExtractorWorker
(
entriesToBeExtracted
,
filePath
));
file
Utils
.
putImgCache
(
fileKey
,
imgUrls
);
file
PreviewCommonService
.
putImgCache
(
fileKey
,
imgUrls
);
return
new
ObjectMapper
().
writeValueAsString
(
appender
.
get
(
""
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
jodconverter-web/src/main/java/cn/keking/web/controller/OnlinePreviewController.java
View file @
0f4f1d58
...
...
@@ -6,7 +6,7 @@ import cn.keking.service.FilePreviewFactory;
import
cn.keking.service.cache.CacheService
;
import
cn.keking.utils.DownloadUtils
;
import
cn.keking.
utils.FileUtils
;
import
cn.keking.
service.FilePreviewCommonService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -32,15 +32,12 @@ public class OnlinePreviewController {
private
final
FilePreviewFactory
previewFactory
;
private
final
CacheService
cacheService
;
private
final
File
Utils
fileUtils
;
private
final
File
PreviewCommonService
filePreviewCommonService
;
private
final
DownloadUtils
downloadUtils
;
public
OnlinePreviewController
(
FilePreviewFactory
filePreviewFactory
,
FileUtils
fileUtils
,
CacheService
cacheService
,
DownloadUtils
downloadUtils
)
{
public
OnlinePreviewController
(
FilePreviewFactory
filePreviewFactory
,
FilePreviewCommonService
filePreviewCommonService
,
CacheService
cacheService
,
DownloadUtils
downloadUtils
)
{
this
.
previewFactory
=
filePreviewFactory
;
this
.
file
Utils
=
fileUtils
;
this
.
file
PreviewCommonService
=
filePreviewCommonService
;
this
.
cacheService
=
cacheService
;
this
.
downloadUtils
=
downloadUtils
;
}
...
...
@@ -48,13 +45,13 @@ public class OnlinePreviewController {
@RequestMapping
(
value
=
"/onlinePreview"
)
public
String
onlinePreview
(
String
url
,
Model
model
,
HttpServletRequest
req
)
{
FileAttribute
fileAttribute
=
file
Utils
.
getFileAttribute
(
url
,
req
);
FileAttribute
fileAttribute
=
file
PreviewCommonService
.
getFileAttribute
(
url
,
req
);
FilePreview
filePreview
=
previewFactory
.
get
(
fileAttribute
);
logger
.
info
(
"预览文件url:{},previewType:{}"
,
url
,
fileAttribute
.
getType
());
return
filePreview
.
filePreviewHandle
(
url
,
model
,
fileAttribute
);
}
@RequestMapping
(
value
=
"picturesPreview"
)
@RequestMapping
(
value
=
"
/
picturesPreview"
)
public
String
picturesPreview
(
Model
model
,
HttpServletRequest
req
)
throws
UnsupportedEncodingException
{
String
urls
=
req
.
getParameter
(
"urls"
);
String
currentUrl
=
req
.
getParameter
(
"currentUrl"
);
...
...
@@ -64,8 +61,8 @@ public class OnlinePreviewController {
String
decodedCurrentUrl
=
URLDecoder
.
decode
(
currentUrl
,
"utf-8"
);
// 抽取文件并返回文件列表
String
[]
imgs
=
decodedUrl
.
split
(
"\\|"
);
List
imgu
rls
=
Arrays
.
asList
(
imgs
);
model
.
addAttribute
(
"img
urls"
,
imgu
rls
);
List
<
String
>
imgU
rls
=
Arrays
.
asList
(
imgs
);
model
.
addAttribute
(
"img
Urls"
,
imgU
rls
);
model
.
addAttribute
(
"currentUrl"
,
decodedCurrentUrl
);
return
"picture"
;
}
...
...
jodconverter-web/src/main/resources/web/picture.ftl
View file @
0f4f1d58
...
...
@@ -23,7 +23,7 @@
</head>
<body>
<ul
id=
"dowebok"
>
<
#
list
img
u
rls
as
img
>
<
#
list
img
U
rls
as
img
>
<
#
if
img
?
contains
("
http:
//")
||
img
?
contains
("
https:
//")
>
<
#
assign
img=
"${img}"
>
<
#
else
>
...
...
jodconverter-web/src/main/resources/web/txt.ftl
View file @
0f4f1d58
...
...
@@ -6,8 +6,8 @@
<title>
普通文本预览
</title>
</head>
<body>
<input
hidden
id=
"textType"
value=
"${textType}"
>
<input
hidden
id=
"textData"
value=
"${textData}"
>
<input
hidden
id=
"textType"
value=
"${textType}"
/
>
<input
hidden
id=
"textData"
value=
"${textData}"
/
>
<div
class=
"container"
>
<
#
if
textType
??
&&
textType =
=
"
markdown
"
>
...
...
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