* tif图片预览,根据反馈的意见,已经全部修改
parent
6387ac21c9
commit
d424de5e9a
|
@ -107,5 +107,5 @@ watermark.height = ${WATERMARK_HEIGHT:80}
|
||||||
watermark.angle = ${WATERMARK_ANGLE:10}
|
watermark.angle = ${WATERMARK_ANGLE:10}
|
||||||
|
|
||||||
#Tif类型图片浏览模式:tif(利用前端js插件浏览);jpg(转换为jpg后前端显示);pdf(转换为pdf后显示,便于打印)
|
#Tif类型图片浏览模式:tif(利用前端js插件浏览);jpg(转换为jpg后前端显示);pdf(转换为pdf后显示,便于打印)
|
||||||
tif.preview.type = ${KK_TIF_PREVIEW_TYPE:pdf}
|
tif.preview.type = ${KK_TIF_PREVIEW_TYPE:tif}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class FileAttribute {
|
||||||
private String url;
|
private String url;
|
||||||
private String fileKey;
|
private String fileKey;
|
||||||
private String officePreviewType = ConfigConstants.getOfficePreviewType();
|
private String officePreviewType = ConfigConstants.getOfficePreviewType();
|
||||||
|
private String previewType;
|
||||||
|
|
||||||
public FileAttribute() {
|
public FileAttribute() {
|
||||||
}
|
}
|
||||||
|
@ -33,6 +34,15 @@ public class FileAttribute {
|
||||||
this.officePreviewType = officePreviewType;
|
this.officePreviewType = officePreviewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileAttribute(FileType type, String suffix, String name, String url, String officePreviewType, String previewType) {
|
||||||
|
this.type = type;
|
||||||
|
this.suffix = suffix;
|
||||||
|
this.name = name;
|
||||||
|
this.url = url;
|
||||||
|
this.officePreviewType = officePreviewType;
|
||||||
|
this.previewType = previewType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFileKey() {
|
public String getFileKey() {
|
||||||
return fileKey;
|
return fileKey;
|
||||||
}
|
}
|
||||||
|
@ -80,4 +90,13 @@ public class FileAttribute {
|
||||||
public void setUrl(String url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPreviewType() {
|
||||||
|
return previewType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviewType(String previewType) {
|
||||||
|
this.previewType = previewType;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,6 +284,11 @@ public class FileHandlerService {
|
||||||
if (StringUtils.hasText(fileKey)) {
|
if (StringUtils.hasText(fileKey)) {
|
||||||
attribute.setFileKey(fileKey);
|
attribute.setFileKey(fileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String previewType = req.getParameter("previewType");
|
||||||
|
if (StringUtils.hasText(previewType)) {
|
||||||
|
attribute.setPreviewType(previewType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return attribute;
|
return attribute;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,11 @@ public class TiffFilePreviewImpl implements FilePreview {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||||
|
|
||||||
String tifPreviewType = ConfigConstants.getTifPreviewType();
|
String tifPreviewType = ConfigConstants.getTifPreviewType();
|
||||||
String priveiwType = String.valueOf(model.getAttribute("previewType"));
|
String previewType = fileAttribute.getPreviewType();
|
||||||
|
if (StringUtils.hasText(previewType)) {
|
||||||
|
tifPreviewType = previewType;
|
||||||
|
}
|
||||||
|
|
||||||
if("tif".equalsIgnoreCase(tifPreviewType)){
|
if("tif".equalsIgnoreCase(tifPreviewType)){
|
||||||
|
|
||||||
|
@ -77,7 +79,7 @@ public class TiffFilePreviewImpl implements FilePreview {
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseUrl = BaseUrlFilter.getBaseUrl();
|
String baseUrl = BaseUrlFilter.getBaseUrl();
|
||||||
if("pdf".equalsIgnoreCase(tifPreviewType) && !"image".equalsIgnoreCase(priveiwType)){
|
if("pdf".equalsIgnoreCase(tifPreviewType)){
|
||||||
File filePdf = ConvertPicUtil.convertJpg2Pdf(fileDir + uuid + ".jpg", fileDir + uuid + ".pdf");
|
File filePdf = ConvertPicUtil.convertJpg2Pdf(fileDir + uuid + ".jpg", fileDir + uuid + ".pdf");
|
||||||
if(filePdf.exists()){
|
if(filePdf.exists()){
|
||||||
String pdfUrl = baseUrl + uuid + ".pdf";
|
String pdfUrl = baseUrl + uuid + ".pdf";
|
||||||
|
|
|
@ -70,10 +70,6 @@ public class OnlinePreviewController {
|
||||||
}
|
}
|
||||||
FileAttribute fileAttribute = fileHandlerService.getFileAttribute(fileUrl, req);
|
FileAttribute fileAttribute = fileHandlerService.getFileAttribute(fileUrl, req);
|
||||||
model.addAttribute("file", fileAttribute);
|
model.addAttribute("file", fileAttribute);
|
||||||
|
|
||||||
String previewType = req.getParameter("previewType");
|
|
||||||
model.addAttribute("previewType", previewType);
|
|
||||||
|
|
||||||
FilePreview filePreview = previewFactory.get(fileAttribute);
|
FilePreview filePreview = previewFactory.get(fileAttribute);
|
||||||
logger.info("预览文件url:{},previewType:{}", fileUrl, fileAttribute.getType());
|
logger.info("预览文件url:{},previewType:{}", fileUrl, fileAttribute.getType());
|
||||||
return filePreview.filePreviewHandle(fileUrl, model, fileAttribute);
|
return filePreview.filePreviewHandle(fileUrl, model, fileAttribute);
|
||||||
|
|
|
@ -37,14 +37,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function goForImage() {
|
function goForImage() {
|
||||||
var url = window.location.href + "&previewType=image"
|
var url = window.location.href + "&previewType=jpg"
|
||||||
console.log(url);
|
|
||||||
if (url.indexOf("officePreviewType=pdf") != -1) {
|
if (url.indexOf("officePreviewType=pdf") != -1) {
|
||||||
url = url.replace("officePreviewType=pdf", "officePreviewType=image");
|
url = url.replace("officePreviewType=pdf", "officePreviewType=image");
|
||||||
} else {
|
} else {
|
||||||
url = url + "&officePreviewType=image";
|
url = url + "&officePreviewType=image";
|
||||||
}
|
}
|
||||||
console.log(url);
|
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue