Compare commits

...

5 Commits
v2.0 ... v2.0.1

Author SHA1 Message Date
795cf3393e 2.0.1版 2019-05-09 15:20:15 +08:00
70323b8ee3 pdf预览支持url中有中文或特殊字符 2019-05-09 15:20:15 +08:00
67686e99f0 修复excel预览网页乱码问题 2019-05-09 15:20:15 +08:00
90554462dc pdf默认预览模式也从配置文件中取,和word ppt统一 2019-05-09 15:20:15 +08:00
kl
ba3084d698 Update README.md 2019-05-09 09:18:54 +08:00
8 changed files with 13 additions and 16 deletions

View File

@ -17,6 +17,7 @@
地址http://file.keking.cn/ 地址http://file.keking.cn/
### 项目文档Project documentation ### 项目文档Project documentation
1. 详细wiki文档https://gitee.com/kekingcn/file-online-preview/wikis/pages
1. 中文文档https://gitee.com/kekingcn/file-online-preview/blob/master/README.md 1. 中文文档https://gitee.com/kekingcn/file-online-preview/blob/master/README.md
1. English documenthttps://github.com/kekingcn/kkFileView/blob/master/README.en.md 1. English documenthttps://github.com/kekingcn/kkFileView/blob/master/README.en.md

View File

@ -12,7 +12,7 @@
<groupId>cn.keking</groupId> <groupId>cn.keking</groupId>
<artifactId>kkFileView</artifactId> <artifactId>kkFileView</artifactId>
<version>2.0</version> <version>2.0.1</version>
<properties> <properties>

View File

@ -4,4 +4,4 @@ cd "%KKFILEVIEW_BIN_FOLDER%"
echo Using KKFILEVIEW_BIN_FOLDER %KKFILEVIEW_BIN_FOLDER% echo Using KKFILEVIEW_BIN_FOLDER %KKFILEVIEW_BIN_FOLDER%
echo Starting kkFileView... echo Starting kkFileView...
echo Please check log file for more information echo Please check log file for more information
java -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider -Dspring.config.location=..\conf\application.properties -jar kkFileView-2.0.jar -> ..\log\kkFileView.log java -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider -Dspring.config.location=..\conf\application.properties -jar kkFileView-2.0.1.jar -> ..\log\kkFileView.log

View File

@ -27,4 +27,4 @@ else
fi fi
echo "Starting kkFileView..." echo "Starting kkFileView..."
echo "Please check log file for more information" echo "Please check log file for more information"
nohup java -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider -Dspring.config.location=../conf/application.properties -jar kkFileView-2.0.jar > ../log/kkFileView.log 2>&1 & nohup java -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider -Dspring.config.location=../conf/application.properties -jar kkFileView-2.0.1.jar > ../log/kkFileView.log 2>&1 &

View File

@ -39,7 +39,7 @@ public class PdfFilePreviewImpl implements FilePreview{
String decodedUrl=fileAttribute.getDecodedUrl(); String decodedUrl=fileAttribute.getDecodedUrl();
String suffix=fileAttribute.getSuffix(); String suffix=fileAttribute.getSuffix();
String fileName=fileAttribute.getName(); String fileName=fileAttribute.getName();
String officePreviewType = model.asMap().get("officePreviewType") == null ? "" : model.asMap().get("officePreviewType").toString(); String officePreviewType = model.asMap().get("officePreviewType") == null ? ConfigConstants.getOfficePreviewType() : model.asMap().get("officePreviewType").toString();
String originUrl = model.asMap().get("originUrl").toString(); String originUrl = model.asMap().get("originUrl").toString();
model.addAttribute("pdfUrl", url); model.addAttribute("pdfUrl", url);
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf"; String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf";

View File

@ -249,7 +249,7 @@ public class FileUtils {
} }
// 重新写入文件 // 重新写入文件
try(FileOutputStream fos = new FileOutputStream(outFilePath); try(FileOutputStream fos = new FileOutputStream(outFilePath);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos))){ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos, "utf-8"))) {
writer.write(sb.toString()); writer.write(sb.toString());
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -15,13 +15,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.*;
import java.io.InputStream; import java.net.*;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -98,7 +93,7 @@ public class OnlinePreviewController {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
String strUrl = urlPath.trim(); String strUrl = urlPath.trim();
URL url = new URL(strUrl); URL url = new URL(new URI(strUrl).toASCIIString());
//打开请求连接 //打开请求连接
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
HttpURLConnection httpURLConnection = (HttpURLConnection) connection; HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
@ -109,7 +104,7 @@ public class OnlinePreviewController {
while (-1 != (len = inputStream.read(bs))) { while (-1 != (len = inputStream.read(bs))) {
resp.getOutputStream().write(bs, 0, len); resp.getOutputStream().write(bs, 0, len);
} }
} catch (IOException e) { } catch (IOException | URISyntaxException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (inputStream != null) { if (inputStream != null) {

View File

@ -12,12 +12,12 @@
</style> </style>
</head> </head>
<body> <body>
<#if pdfUrl?contains("http://")> <#if pdfUrl?contains("http://") || pdfUrl?contains("https://")>
<#assign finalUrl="${pdfUrl}"> <#assign finalUrl="${pdfUrl}">
<#else> <#else>
<#assign finalUrl="${baseUrl}${pdfUrl}"> <#assign finalUrl="${baseUrl}${pdfUrl}">
</#if> </#if>
<iframe src="/pdfjs/web/viewer.html?file=${finalUrl}" width="100%" frameborder="0"></iframe> <iframe src="" width="100%" frameborder="0"></iframe>
<#-- <img src="images/left.png" style="position: fixed; cursor: pointer; top: 40%; right: 60px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>--> <#-- <img src="images/left.png" style="position: fixed; cursor: pointer; top: 40%; right: 60px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>-->
<span class="fa fa-file-image-o fa-5x" style="position: fixed; cursor: pointer; top: 40%; right: 50px; z-index: 999;" title="使用图片预览" onclick="goForImage()"></span> <span class="fa fa-file-image-o fa-5x" style="position: fixed; cursor: pointer; top: 40%; right: 50px; z-index: 999;" title="使用图片预览" onclick="goForImage()"></span>
@ -25,6 +25,7 @@
</body> </body>
<script type="text/javascript"> <script type="text/javascript">
document.getElementsByTagName('iframe')[0].src = "/pdfjs/web/viewer.html?file="+encodeURIComponent('${finalUrl}');
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight-10; document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight-10;
/** /**
* 页面变化调整高度 * 页面变化调整高度