Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdf-html
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
施贇杰
pdf-html
Commits
8e872566
Commit
8e872566
authored
Apr 13, 2022
by
shiyunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update viewer
parent
bd2e49ca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
11 deletions
+28
-11
README.md
README.md
+3
-3
viewer.css
iframe/web/viewer.css
+2
-2
viewer.html
iframe/web/viewer.html
+19
-5
viewer.js
iframe/web/viewer.js
+4
-1
No files found.
README.md
View file @
8e872566
# pdf-html
# pdf-html
### 简介
### 简介
引用pdf.js
iframe方式
浏览pdf文件,支持手势缩放,滚动页数
引用pdf.js 浏览pdf文件,支持手势缩放,滚动页数
### 使用
### 使用
部署后直接访问
iframe
.html
部署后直接访问
web/viewer
.html
```
js
```
js
https
:
//oest.aia.com.cn/oap/es/com/pdf/
iframe.html?
https://oest.aia.com.cn/oap/es/com/test/test.pdf
https
:
//oest.aia.com.cn/oap/es/com/pdf/
web/viewer.html?file=
https://oest.aia.com.cn/oap/es/com/test/test.pdf
```
```
iframe/web/viewer.css
View file @
8e872566
...
@@ -411,8 +411,8 @@ html {
...
@@ -411,8 +411,8 @@ html {
body
{
body
{
height
:
100%
;
height
:
100%
;
width
:
100%
;
width
:
100%
;
background-color
:
#
404040
;
background-color
:
#
cccccc
;
background-image
:
url(images/texture.png)
;
/*background-image: url(images/texture.png);*/
}
}
body
,
body
,
...
...
iframe/web/viewer.html
View file @
8e872566
...
@@ -106,7 +106,12 @@ See https://github.com/adobe-type-tools/cmap-resources
...
@@ -106,7 +106,12 @@ See https://github.com/adobe-type-tools/cmap-resources
const
reset
=
()
=>
{
startX
=
startY
=
initialPinchDistance
=
0
;
pinchScale
=
1
;
};
const
reset
=
()
=>
{
startX
=
startY
=
initialPinchDistance
=
0
;
pinchScale
=
1
;
};
// Prevent native iOS page zoom
// Prevent native iOS page zoom
document
.
addEventListener
(
"touchmove"
,
(
e
)
=>
{
if
(
e
.
scale
!==
1
&&
isiOSXZ
)
{
e
.
preventDefault
();
}
},
{
passive
:
false
});
document
.
addEventListener
(
"touchmove"
,
(
e
)
=>
{
if
(
e
.
scale
!==
1
&&
isiOSXZ
)
{
e
.
preventDefault
();
}
},
{
passive
:
false
});
viewer
.
addEventListener
(
"touchstart"
,
(
e
)
=>
{
viewer
.
addEventListener
(
"touchstart"
,
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
...
@@ -120,8 +125,11 @@ See https://github.com/adobe-type-tools/cmap-resources
...
@@ -120,8 +125,11 @@ See https://github.com/adobe-type-tools/cmap-resources
});
});
viewer
.
addEventListener
(
"touchmove"
,
(
e
)
=>
{
viewer
.
addEventListener
(
"touchmove"
,
(
e
)
=>
{
if
(
initialPinchDistance
<=
0
||
e
.
touches
.
length
<
2
)
{
return
;
}
console
.
log
(
'viewer_touchmove'
)
if
(
initialPinchDistance
<=
0
||
e
.
touches
.
length
<
2
)
{
return
;
}
console
.
log
(
'viewer_touchmove_do'
)
const
pinchDistance
=
Math
.
hypot
((
e
.
touches
[
1
].
pageX
-
e
.
touches
[
0
].
pageX
),
(
e
.
touches
[
1
].
pageY
-
e
.
touches
[
0
].
pageY
));
const
pinchDistance
=
Math
.
hypot
((
e
.
touches
[
1
].
pageX
-
e
.
touches
[
0
].
pageX
),
(
e
.
touches
[
1
].
pageY
-
e
.
touches
[
0
].
pageY
));
const
originX
=
startX
+
container
.
scrollLeft
;
const
originX
=
startX
+
container
.
scrollLeft
;
const
originY
=
startY
+
container
.
scrollTop
;
const
originY
=
startY
+
container
.
scrollTop
;
...
@@ -148,7 +156,7 @@ See https://github.com/adobe-type-tools/cmap-resources
...
@@ -148,7 +156,7 @@ See https://github.com/adobe-type-tools/cmap-resources
});
});
}
}
//
if(!isWeixin){
/*
if(!isWeixin){
document.addEventListener('webviewerloaded', () => {
document.addEventListener('webviewerloaded', () => {
console.log('webviewerloaded');
console.log('webviewerloaded');
//console.log('webviewerloaded:pinchZoomEnabled', pinchZoomEnabled)
//console.log('webviewerloaded:pinchZoomEnabled', pinchZoomEnabled)
...
@@ -157,10 +165,11 @@ See https://github.com/adobe-type-tools/cmap-resources
...
@@ -157,10 +165,11 @@ See https://github.com/adobe-type-tools/cmap-resources
enablePinchZoom();
enablePinchZoom();
}
}
});
});
//}
}*/
</script>
</script>
<body
tabindex=
"1"
class=
"loadingInProgress"
>
<body
tabindex=
"1"
class=
"loadingInProgress"
>
<div
id=
"outerContainer"
>
<div
id=
"outerContainer"
>
<div
id=
"sidebarContainer"
>
<div
id=
"sidebarContainer"
>
...
@@ -1046,5 +1055,10 @@ See https://github.com/adobe-type-tools/cmap-resources
...
@@ -1046,5 +1055,10 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
<!-- outerContainer -->
<!-- outerContainer -->
<div
id=
"printContainer"
></div>
<div
id=
"printContainer"
></div>
<script
src=
"https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"
></script >
<script >
// 初始化
let
vConsole
=
new
VConsole
();
</script >
</body>
</body>
</html>
</html>
iframe/web/viewer.js
View file @
8e872566
...
@@ -1793,7 +1793,7 @@ function webViewerInitialized() {
...
@@ -1793,7 +1793,7 @@ function webViewerInitialized() {
var
file
;
var
file
;
var
queryString
=
document
.
location
.
search
.
substring
(
1
);
var
queryString
=
document
.
location
.
search
.
substring
(
1
);
var
params
=
(
0
,
_ui_utils
.
parseQueryString
)(
queryString
);
var
params
=
(
0
,
_ui_utils
.
parseQueryString
)(
queryString
);
file
=
'file'
in
params
?
params
.
file
:
_app_options
.
AppOptions
.
get
(
'defaultUrl'
)
;
file
=
'file'
in
params
?
params
.
file
:
''
;
validateFileURL
(
file
);
validateFileURL
(
file
);
var
fileInput
=
document
.
createElement
(
'input'
);
var
fileInput
=
document
.
createElement
(
'input'
);
fileInput
.
id
=
appConfig
.
openFileInputName
;
fileInput
.
id
=
appConfig
.
openFileInputName
;
...
@@ -1877,6 +1877,9 @@ var webViewerOpenFileViaURL;
...
@@ -1877,6 +1877,9 @@ var webViewerOpenFileViaURL;
{
{
webViewerOpenFileViaURL
=
function
webViewerOpenFileViaURL
(
file
)
{
webViewerOpenFileViaURL
=
function
webViewerOpenFileViaURL
(
file
)
{
var
sURL
=
window
.
sessionStorage
.
getItem
(
'file'
)
||
file
;
var
sURL
=
window
.
sessionStorage
.
getItem
(
'file'
)
||
file
;
if
(
!
sURL
){
sURL
=
(
0
,
_ui_utils
.
parseQueryString
)(
'file'
);
}
if
(
file
&&
file
.
lastIndexOf
(
'file:'
,
0
)
===
0
)
{
if
(
file
&&
file
.
lastIndexOf
(
'file:'
,
0
)
===
0
)
{
PDFViewerApplication
.
setTitleUsingUrl
(
file
);
PDFViewerApplication
.
setTitleUsingUrl
(
file
);
console
.
log
(
'XMLHttpRequest:'
,
file
.
split
(
'&'
))
console
.
log
(
'XMLHttpRequest:'
,
file
.
split
(
'&'
))
...
...
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