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
70323b8e
Commit
70323b8e
authored
May 09, 2019
by
陈精华
Committed by
kl
May 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdf预览支持url中有中文或特殊字符
parent
67686e99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
OnlinePreviewController.java
...ava/cn/keking/web/controller/OnlinePreviewController.java
+4
-9
pdf.ftl
jodconverter-web/src/main/resources/web/pdf.ftl
+3
-2
No files found.
jodconverter-web/src/main/java/cn/keking/web/controller/OnlinePreviewController.java
View file @
70323b8e
...
@@ -15,13 +15,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -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 {
...
@@ -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 {
...
@@ -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
)
{
...
...
jodconverter-web/src/main/resources/web/pdf.ftl
View file @
70323b8e
...
@@ -12,12 +12,12 @@
...
@@ -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 @@
...
@@ -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
;
/**
/**
* 页面变化调整高度
* 页面变化调整高度
...
...
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