Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
ece7f8d5
Unverified
Commit
ece7f8d5
authored
Oct 15, 2024
by
Kaiwen Liu
Committed by
GitHub
Oct 15, 2024
Browse files
Merge pull request #6 from opendatalab/dev
Dev
parents
98362a6e
702b6ac9
Changes
551
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
373 additions
and
0 deletions
+373
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-secondaryToolbarToggle.svg
...-dist/web/images/toolbarButton-secondaryToolbarToggle.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-sidebarToggle-open.svg
...dfjs-dist/web/images/toolbarButton-sidebarToggle-open.svg
+10
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-sidebarToggle.svg
...lic/pdfjs-dist/web/images/toolbarButton-sidebarToggle.svg
+7
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewAttachments.svg
...c/pdfjs-dist/web/images/toolbarButton-viewAttachments.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewLayers.svg
...public/pdfjs-dist/web/images/toolbarButton-viewLayers.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewOutline.svg
...ublic/pdfjs-dist/web/images/toolbarButton-viewOutline.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewThumbnail.svg
...lic/pdfjs-dist/web/images/toolbarButton-viewThumbnail.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-zoomIn.svg
...web/public/pdfjs-dist/web/images/toolbarButton-zoomIn.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/toolbarButton-zoomOut.svg
...eb/public/pdfjs-dist/web/images/toolbarButton-zoomOut.svg
+3
-0
projects/web/public/pdfjs-dist/web/images/treeitem-collapsed.svg
...s/web/public/pdfjs-dist/web/images/treeitem-collapsed.svg
+1
-0
projects/web/public/pdfjs-dist/web/images/treeitem-expanded.svg
...ts/web/public/pdfjs-dist/web/images/treeitem-expanded.svg
+1
-0
projects/web/public/pdfjs-dist/web/layer.js
projects/web/public/pdfjs-dist/web/layer.js
+333
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitDingbats.pfb
...eb/public/pdfjs-dist/web/standard_fonts/FoxitDingbats.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixed.pfb
...s/web/public/pdfjs-dist/web/standard_fonts/FoxitFixed.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixedBold.pfb
...b/public/pdfjs-dist/web/standard_fonts/FoxitFixedBold.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixedBoldItalic.pfb
...ic/pdfjs-dist/web/standard_fonts/FoxitFixedBoldItalic.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixedItalic.pfb
...public/pdfjs-dist/web/standard_fonts/FoxitFixedItalic.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitSerif.pfb
...s/web/public/pdfjs-dist/web/standard_fonts/FoxitSerif.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitSerifBold.pfb
...b/public/pdfjs-dist/web/standard_fonts/FoxitSerifBold.pfb
+0
-0
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitSerifBoldItalic.pfb
...ic/pdfjs-dist/web/standard_fonts/FoxitSerifBoldItalic.pfb
+0
-0
No files found.
projects/web/public/pdfjs-dist/web/images/toolbarButton-secondaryToolbarToggle.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M2.53406 13.818L7.99906 8.35203L8.00006 7.64703L2.53606 2.18203C2.41769 2.06965 2.26012 2.00795 2.09692 2.01006C1.93372 2.01218 1.7778 2.07795 1.66239 2.19336C1.54698 2.30877 1.48121 2.46469 1.47909 2.62789C1.47697 2.79109 1.53868 2.94867 1.65106 3.06703L6.58506 7.99803L1.65006 12.932C1.53754 13.0503 1.47565 13.2078 1.47758 13.371C1.47951 13.5342 1.54511 13.6902 1.66039 13.8057C1.77567 13.9213 1.93152 13.9872 2.09472 13.9895C2.25792 13.9918 2.41557 13.9303 2.53406 13.818ZM8.53406 13.818L13.9991 8.35203L14.0001 7.64703L8.53606 2.18203C8.4177 2.06965 8.26012 2.00795 8.09692 2.01006C7.93372 2.01218 7.7778 2.07795 7.66239 2.19336C7.54698 2.30877 7.48121 2.46469 7.47909 2.62789C7.47697 2.79109 7.53868 2.94867 7.65106 3.06703L12.5851 7.99803L7.65006 12.932C7.53754 13.0503 7.47565 13.2078 7.47758 13.371C7.47951 13.5342 7.54511 13.6902 7.66039 13.8057C7.77567 13.9213 7.93152 13.9872 8.09472 13.9895C8.25792 13.9918 8.41557 13.9303 8.53406 13.818Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-sidebarToggle-open.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"17"
viewBox=
"0 0 16 17"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<g
id=
"MenuFoldOutlined"
>
<g
id=
"Vector"
>
<path
d=
"M1.14648 3.9918C1.14648 3.62361 1.44496 3.32513 1.81315 3.32513H13.8132C14.1813 3.32513 14.4798 3.62361 14.4798 3.9918C14.4798 4.35999 14.1813 4.65847 13.8132 4.65847H1.81315C1.44496 4.65847 1.14648 4.35999 1.14648 3.9918Z"
fill=
"#464A53"
/>
<path
d=
"M6.19303 8.50002C6.19303 8.13183 6.49151 7.83335 6.8597 7.83335L13.813 7.83335C14.1812 7.83335 14.4797 8.13183 14.4797 8.50002C14.4797 8.86821 14.1812 9.16669 13.813 9.16669L6.8597 9.16669C6.49151 9.16669 6.19303 8.86821 6.19303 8.50002Z"
fill=
"#464A53"
/>
<path
d=
"M1.14648 13.0055C1.14648 12.6373 1.44496 12.3388 1.81315 12.3388H13.8132C14.1813 12.3388 14.4798 12.6373 14.4798 13.0055C14.4798 13.3737 14.1813 13.6721 13.8132 13.6721H1.81315C1.44496 13.6721 1.14648 13.3737 1.14648 13.0055Z"
fill=
"#464A53"
/>
<path
d=
"M3.70949 6.68469C3.91501 6.55624 4.17403 6.54944 4.386 6.66693C4.59797 6.78441 4.72949 7.00767 4.72949 7.25002V9.75002C4.72949 9.99237 4.59797 10.2156 4.386 10.3331C4.17403 10.4506 3.91501 10.4438 3.70949 10.3154L1.70949 9.06535C1.51457 8.94353 1.39616 8.72988 1.39616 8.50002C1.39616 8.27016 1.51457 8.05651 1.70949 7.93469L3.70949 6.68469Z"
fill=
"#464A53"
/>
</g>
</g>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-sidebarToggle.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<rect
x=
"1.98438"
y=
"3.53418"
width=
"12.1003"
height=
"9.14041"
rx=
"0.888889"
stroke=
"#464A53"
stroke-width=
"1.33333"
/>
<path
d=
"M7.04297 3.53418L7.04297 12.6746"
stroke=
"#464A53"
stroke-width=
"1.18222"
/>
<path
d=
"M3.86523 5.71484H5.24197"
stroke=
"#464A53"
stroke-width=
"1.18222"
stroke-linecap=
"round"
/>
<path
d=
"M3.86523 7.5918H5.24197"
stroke=
"#464A53"
stroke-width=
"1.18222"
stroke-linecap=
"round"
/>
<path
d=
"M3.86523 9.46826H5.24197"
stroke=
"#464A53"
stroke-width=
"1.18222"
stroke-linecap=
"round"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewAttachments.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M3.5 3.75C3.5 1.67879 5.17879 0 7.25 0C9.32121 0 11 1.67879 11 3.75V10.25C11 11.4922 9.99221 12.5 8.75 12.5C7.50779 12.5 6.5 11.4922 6.5 10.25V3.5H8V10.25C8 10.6638 8.33621 11 8.75 11C9.16379 11 9.5 10.6638 9.5 10.25V3.75C9.5 2.50721 8.49279 1.5 7.25 1.5C6.00721 1.5 5 2.50721 5 3.75V10.75C5 12.8208 6.67921 14.5 8.75 14.5C10.8208 14.5 12.5 12.8208 12.5 10.75V3.5H14V10.75C14 13.6492 11.6492 16 8.75 16C5.85079 16 3.5 13.6492 3.5 10.75V3.75Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewLayers.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M8.36645 2.34562C8.13878 2.21813 7.86122 2.21813 7.63355 2.34562L1.38355 5.84562C1.14669 5.97826 1 6.22853 1 6.5C1 6.77147 1.14669 7.02174 1.38355 7.15438L7.63355 10.6544C7.86122 10.7819 8.13878 10.7819 8.36645 10.6544L14.6165 7.15438C14.8533 7.02174 15 6.77147 15 6.5C15 6.22853 14.8533 5.97826 14.6165 5.84562L8.36645 2.34562ZM8 9.14041L3.28499 6.5L8 3.85959L12.715 6.5L8 9.14041ZM1.63647 9.0766L7.99999 12.6404L14.3255 9.09761L15.0585 10.4063L8.36649 14.1543C8.13881 14.2818 7.86122 14.2819 7.63353 14.1543L0.903534 10.3853L1.63647 9.0766Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewOutline.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M3 1.25H15V2.75H3V1.25ZM15 5.25H3V6.75H15V5.25ZM15 13.25H3V14.75H15V13.25ZM15 9.25H6V10.75H15V9.25ZM0 5.25H1.5V6.75H0V5.25ZM1.5 13.25H0V14.75H1.5V13.25ZM0 1.25H1.5V2.75H0V1.25ZM4.5 9.25H3V10.75H4.5V9.25Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-viewThumbnail.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M3.5 2C3.5 1.72421 3.72421 1.5 4 1.5H5.25C5.52579 1.5 5.75 1.72421 5.75 2V5.25C5.75 5.52579 5.52579 5.75 5.25 5.75H4C3.72421 5.75 3.5 5.52579 3.5 5.25V2ZM4 0C2.89579 0 2 0.895786 2 2V5.25C2 6.35421 2.89579 7.25 4 7.25H5.25C6.35421 7.25 7.25 6.35421 7.25 5.25V2C7.25 0.895786 6.35421 0 5.25 0H4ZM3.5 10.75C3.5 10.4742 3.72421 10.25 4 10.25H5.25C5.52579 10.25 5.75 10.4742 5.75 10.75V14C5.75 14.2758 5.52579 14.5 5.25 14.5H4C3.72421 14.5 3.5 14.2758 3.5 14V10.75ZM4 8.75C2.89579 8.75 2 9.64579 2 10.75V14C2 15.1042 2.89579 16 4 16H5.25C6.35421 16 7.25 15.1042 7.25 14V10.75C7.25 9.64579 6.35421 8.75 5.25 8.75H4ZM10.75 1.5C10.4742 1.5 10.25 1.72421 10.25 2V5.25C10.25 5.52579 10.4742 5.75 10.75 5.75H12C12.2758 5.75 12.5 5.52579 12.5 5.25V2C12.5 1.72421 12.2758 1.5 12 1.5H10.75ZM8.75 2C8.75 0.895786 9.64579 0 10.75 0H12C13.1042 0 14 0.895786 14 2V5.25C14 6.35421 13.1042 7.25 12 7.25H10.75C9.64579 7.25 8.75 6.35421 8.75 5.25V2ZM10.25 10.75C10.25 10.4742 10.4742 10.25 10.75 10.25H12C12.2758 10.25 12.5 10.4742 12.5 10.75V14C12.5 14.2758 12.2758 14.5 12 14.5H10.75C10.4742 14.5 10.25 14.2758 10.25 14V10.75ZM10.75 8.75C9.64579 8.75 8.75 9.64579 8.75 10.75V14C8.75 15.1042 9.64579 16 10.75 16H12C13.1042 16 14 15.1042 14 14V10.75C14 9.64579 13.1042 8.75 12 8.75H10.75Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-zoomIn.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M7.00488 9.75V14C7.00488 14.1658 7.07073 14.3247 7.18794 14.4419C7.30515 14.5592 7.46412 14.625 7.62988 14.625C7.79564 14.625 7.95461 14.5592 8.07183 14.4419C8.18904 14.3247 8.25488 14.1658 8.25488 14V9.75L8.75488 9.25H13.0049C13.1706 9.25 13.3296 9.18415 13.4468 9.06694C13.564 8.94973 13.6299 8.79076 13.6299 8.625C13.6299 8.45924 13.564 8.30027 13.4468 8.18306C13.3296 8.06585 13.1706 8 13.0049 8H8.75488L8.25488 7.5V3.25C8.25488 3.08424 8.18904 2.92527 8.07183 2.80806C7.95461 2.69085 7.79564 2.625 7.62988 2.625C7.46412 2.625 7.30515 2.69085 7.18794 2.80806C7.07073 2.92527 7.00488 3.08424 7.00488 3.25V7.5L6.50488 8H2.25488C2.08912 8 1.93015 8.06585 1.81294 8.18306C1.69573 8.30027 1.62988 8.45924 1.62988 8.625C1.62988 8.79076 1.69573 8.94973 1.81294 9.06694C1.93015 9.18415 2.08912 9.25 2.25488 9.25H6.39188L7.00488 9.75Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/toolbarButton-zoomOut.svg
0 → 100644
View file @
ece7f8d5
<svg
width=
"16"
height=
"16"
viewBox=
"0 0 16 16"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M13.375 9.25C13.5408 9.25 13.6997 9.18415 13.8169 9.06694C13.9342 8.94973 14 8.79076 14 8.625C14 8.45924 13.9342 8.30027 13.8169 8.18306C13.6997 8.06585 13.5408 8 13.375 8H2.625C2.45924 8 2.30027 8.06585 2.18306 8.18306C2.06585 8.30027 2 8.45924 2 8.625C2 8.79076 2.06585 8.94973 2.18306 9.06694C2.30027 9.18415 2.45924 9.25 2.625 9.25H13.375Z"
fill=
"black"
/>
</svg>
projects/web/public/pdfjs-dist/web/images/treeitem-collapsed.svg
0 → 100644
View file @
ece7f8d5
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"16"
height=
"16"
><path
d=
"M13 9L6 5v8z"
/></svg>
\ No newline at end of file
projects/web/public/pdfjs-dist/web/images/treeitem-expanded.svg
0 → 100644
View file @
ece7f8d5
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"16"
height=
"16"
><path
d=
"M10 13l4-7H6z"
/></svg>
\ No newline at end of file
projects/web/public/pdfjs-dist/web/layer.js
0 → 100644
View file @
ece7f8d5
var
LAYER_CHANGE_ACTIVE_CLASS
=
'
layerChange-active
'
// 获取 button 元素
var
layerChangeButton
=
document
.
getElementById
(
'
layerChange
'
);
var
isLayerChangeButtonActive
=
()
=>
{
return
layerChangeButton
.
classList
.
contains
(
LAYER_CHANGE_ACTIVE_CLASS
)
}
var
getLocale
=
()
=>
{
console
.
log
(
'
test-iframe-locale
'
,
localStorage
.
getItem
(
'
umi-locale
'
)
,
localStorage
.
getItem
(
'
locale
'
)
,
''
)
return
localStorage
.
getItem
(
'
umi_locale
'
)
||
localStorage
.
getItem
(
'
locale
'
)
||
'
zh-CN
'
;
}
// 添加tooltip
function
createHoverTooltip
(
element
,
tooltipText
,
id
,
options
=
{})
{
const
tooltip
=
document
.
createElement
(
'
div
'
);
tooltip
.
className
=
`tooltip-
${
id
}
tooltip`
;
tooltip
.
style
.
display
=
'
none
'
;
tooltip
.
style
.
zIndex
=
'
999
'
;
document
.
body
.
appendChild
(
tooltip
);
const
defaultOptions
=
{
offset
:
{
y
:
10
},
delay
:
200
,
duration
:
200
,
};
const
mergedOptions
=
{
...
defaultOptions
,
...
options
};
let
tooltipTimer
;
function
positionTooltip
()
{
const
rect
=
element
.
getBoundingClientRect
();
const
tooltipRect
=
tooltip
.
getBoundingClientRect
();
const
left
=
rect
.
left
+
(
rect
.
width
-
tooltipRect
.
width
)
/
2
;
const
top
=
rect
.
bottom
+
mergedOptions
.
offset
.
y
;
tooltip
.
style
.
left
=
`
${
left
}
px`
;
tooltip
.
style
.
top
=
`
${
top
}
px`
;
}
function
showTooltip
()
{
tooltip
.
textContent
=
tooltipText
;
tooltip
.
style
.
display
=
'
block
'
;
tooltip
.
style
.
opacity
=
'
0
'
;
tooltip
.
style
.
transition
=
`opacity
${
mergedOptions
.
duration
}
ms`
;
positionTooltip
();
setTimeout
(()
=>
{
tooltip
.
style
.
opacity
=
'
1
'
;
},
10
);
}
function
hideTooltip
()
{
tooltip
.
style
.
opacity
=
'
0
'
;
setTimeout
(()
=>
{
tooltip
.
style
.
display
=
'
none
'
;
},
mergedOptions
.
duration
);
}
element
.
addEventListener
(
'
mouseenter
'
,
()
=>
{
tooltipTimer
=
setTimeout
(
showTooltip
,
mergedOptions
.
delay
);
});
element
.
addEventListener
(
'
mouseleave
'
,
()
=>
{
clearTimeout
(
tooltipTimer
);
hideTooltip
();
});
window
.
addEventListener
(
'
resize
'
,
positionTooltip
);
window
.
addEventListener
(
'
scroll
'
,
positionTooltip
);
// 返回对象,包含 updateTooltipText 函数
return
{
updateTooltipText
:
(
newText
)
=>
{
tooltipText
=
newText
;
positionTooltip
()
if
(
tooltip
.
style
.
display
!==
'
none
'
)
{
showTooltip
();
tooltipText
=
newText
;
}
}
};
}
const
tooltipLayer
=
createHoverTooltip
(
layerChangeButton
,
getLocale
()
===
'
zh-CN
'
?
'
隐藏识别结果
'
:
'
Hide recognition results
'
,
'
layerChange
'
,
{
offset
:
{
y
:
22
}
});
window
.
addEventListener
(
'
storage
'
,
function
(
event
)
{
// 检查事件是否与监听的键相关
if
(
event
.
key
===
'
umi_locale
'
||
event
.
key
===
'
locale
'
)
{
const
text
=
isLayerChangeButtonActive
()
?
event
?.
newValue
===
'
zh-CN
'
?
'
隐藏识别结果
'
:
'
Hide recognition results
'
:
getLocale
()
===
'
zh-CN
'
?
'
显示识别结果
'
:
'
Display recognition results
'
tooltipLayer
?.
updateTooltipText
(
text
)
}
});
// 添加点击事件监听器
layerChangeButton
.
addEventListener
(
'
click
'
,
function
()
{
// 检查当前 button 的选中状态
if
(
isLayerChangeButtonActive
())
{
// 如果已经处于选中状态,则移除选中状态的 class
const
annotationLayerList
=
document
.
getElementsByClassName
(
'
annotationLayer
'
)
Array
?.
from
(
annotationLayerList
)?.
forEach
(
element
=>
{
var
extractLayer
=
element
.
querySelector
(
'
#extractLayer
'
);
if
(
extractLayer
)
{
extractLayer
.
style
.
opacity
=
0
}
});
console
.
log
(
'
test-dd
'
,
annotationLayerList
,
typeof
annotationLayerList
)
tooltipLayer
?.
updateTooltipText
(
getLocale
()
===
'
zh-CN
'
?
'
显示识别结果
'
:
'
Display recognition results
'
)
this
.
classList
.
remove
(
LAYER_CHANGE_ACTIVE_CLASS
);
}
else
{
// 如果未处于选中状态,则添加选中状态的 class
this
.
classList
.
add
(
LAYER_CHANGE_ACTIVE_CLASS
);
tooltipLayer
?.
updateTooltipText
(
getLocale
()
===
'
zh-CN
'
?
'
隐藏识别结果
'
:
'
Hide recognition results
'
)
const
scale
=
0.943
/
0.7071
*
window
?.
PDFViewerApplication
?.
pdfViewer
?.
_currentScale
||
1
window
.
renderExtractLayer
(
window
.
pdfExtractData
,
Number
(
0
),
scale
)
const
annotationLayerList
=
document
.
getElementsByClassName
(
'
annotationLayer
'
)
Array
?.
from
(
annotationLayerList
)?.
forEach
(
element
=>
{
var
extractLayer
=
element
.
querySelector
(
'
#extractLayer
'
);
if
(
extractLayer
)
{
extractLayer
.
style
.
opacity
=
1
}
})
}
});
// 获取显示消息的元素
const
messageDisplay
=
document
.
getElementById
(
'
messageDisplay
'
);
function
removeDuplicates
(
arr
)
{
return
[...
new
Set
(
arr
)];
}
window
.
addEventListener
(
'
error
'
,
function
(
event
)
{
if
(
event
.
target
&&
event
.
target
.
tagName
===
'
SCRIPT
'
)
{
console
.
error
(
"
Script error detected:
"
,
event
);
}
},
true
);
// 添加消息监听器
window
.
addEventListener
(
'
message
'
,
function
(
event
)
{
const
receivedMessage
=
event
.
data
;
const
data
=
receivedMessage
?.
data
const
type
=
receivedMessage
?.
type
function
setHasRenderAnimatedPage
(
num
)
{
if
(
!
window
.
hasRenderAnimatedPage
)
{
window
.
hasRenderAnimatedPage
=
[]
}
if
(
typeof
window
.
hasRenderAnimatedPage
===
'
object
'
){
window
.
hasRenderAnimatedPage
=
removeDuplicates
([...
window
.
hasRenderAnimatedPage
,
num
])
}
}
let
animatingBox
=
new
Map
()
function
renderExtractLayer
(
data
,
pageNum
,
scale
)
{
// 判断按钮是开的还是关的
if
(
!
isLayerChangeButtonActive
())
return
;
const
bboxes
=
data
?.[
pageNum
]?.
bboxes
||
[]
function
drawBoxes
(
boxes
,
scale
)
{
if
(
animatingBox
.
get
(
pageNum
))
return
// const annotationLayer = document.querySelector('.canvasWrapper');
const
pageLayer
=
document
.
getElementsByClassName
(
'
page
'
)?.[
pageNum
]
const
annotationLayer
=
pageLayer
.
querySelectorAll
(
'
.annotationLayer
'
)?.[
0
];
// annotationLayer.removeAttribute('hidden');
if
(
!
annotationLayer
)
{
// console.error('error: annotationLayer has not been rendered')
return
}
const
extractLayer
=
annotationLayer
.
querySelector
(
'
#extractLayer
'
);
// 因为pdfjs只会缓存8页的内容,所以采用每次切换移除重建canvas的方式
if
(
extractLayer
)
{
extractLayer
?.
remove
();
}
annotationLayer
.
style
.
width
=
'
100%
'
;
annotationLayer
.
style
.
height
=
'
100%
'
annotationLayer
.
style
.
position
=
'
absolute
'
;
annotationLayer
.
style
.
top
=
0
;
annotationLayer
.
style
.
left
=
0
;
const
computedLayer
=
document
.
querySelector
(
'
.canvasWrapper
'
);
const
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
id
=
'
extractLayer
'
const
w
=
pageLayer
?.
offsetWidth
-
18
;
const
h
=
pageLayer
?.
offsetHeight
-
18
;
canvas
.
width
=
true
?
`
${
w
}
`
:
'
100%
'
;
canvas
.
height
=
true
?
`
${
h
}
`
:
'
100%
'
;
canvas
.
style
.
width
=
true
?
`
${
w
}
px`
:
'
100%
'
;
canvas
.
style
.
height
=
true
?
`
${
h
}
px`
:
'
100%
'
;
canvas
.
style
.
position
=
'
absolute
'
;
canvas
.
style
.
top
=
0
;
canvas
.
style
.
left
=
0
;
annotationLayer
.
append
(
canvas
)
const
ctx
=
canvas
.
getContext
(
'
2d
'
);
// 移除之前的画布内容
// ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx
.
save
();
// console.log('renderExtractLayer: draw boxes')
function
drawPartialRect
(
ctx
,
box
,
progress
,
scale
)
{
const
[
x
,
y
,
x2
,
y2
]
=
box
.
bbox
.
map
((
i
)
=>
(
i
*
scale
));
const
width
=
x2
-
x
;
const
height
=
y2
-
y
;
const
color
=
box
?.
color
?.
line
const
fillColor
=
box
?.
color
?.
fill
ctx
.
beginPath
();
ctx
.
strokeStyle
=
color
;
// 左边竖线
ctx
.
moveTo
(
x
,
y
);
ctx
.
lineTo
(
x
,
y2
);
// 上边横线
ctx
.
moveTo
(
x
,
y
);
ctx
.
lineTo
(
x
+
width
*
(
progress
<
0
?
0
:
progress
),
y
);
// 右边竖线 (只在进度完成时绘制)
if
(
progress
===
1
)
{
ctx
.
moveTo
(
x2
,
y
);
ctx
.
lineTo
(
x2
,
y2
);
ctx
.
fillStyle
=
fillColor
;
ctx
.
fillRect
(
x
,
y
,
width
,
height
);
}
// 下边横线
ctx
.
moveTo
(
x
,
y2
);
ctx
.
lineTo
(
x
+
width
*
(
progress
<
0
?
0
:
progress
),
y2
);
ctx
.
stroke
();
}
function
fillRect
(
ctx
,
box
,
scale
)
{
const
[
x
,
y
,
x2
,
y2
]
=
box
.
bbox
.
map
((
i
)
=>
(
i
*
scale
));
const
width
=
x2
-
x
;
const
height
=
y2
-
y
;
const
color
=
box
?.
color
?.
fill
ctx
.
fillStyle
=
color
;
ctx
.
fillRect
(
x
,
y
,
width
,
height
);
}
function
animateBox
(
ctx
,
box
,
duration
=
1000
)
{
const
startTime
=
performance
.
now
();
function
animate
(
currentTime
)
{
const
elapsedTime
=
currentTime
-
startTime
;
const
progress
=
Math
.
min
(
elapsedTime
/
duration
,
1
);
// ctx.clearRect(...box.bbox); // 清除之前的绘制
drawPartialRect
(
ctx
,
box
,
progress
,
scale
);
if
(
progress
<
1
)
{
requestAnimationFrame
(
animate
);
}
}
requestAnimationFrame
(
animate
);
}
async
function
animateAllBoxes
()
{
// const [index, value] of array.entries()
for
(
const
[
index
,
box
]
of
boxes
?.
entries
())
{
await
animateBox
(
ctx
,
box
,
600
);
// 动画时间改为500ms
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
200
));
// 每个框之间的延迟也减少到100ms
}
// 所有线框动画完成后,一次性填充所有矩形
// ctx.clearRect(...box.bbox); // 清除之前的绘制
// boxes.forEach(box => fillRect(ctx, box, scale));
console
.
log
(
"
test-animate All animations completed and boxes filled
"
);
animatingBox
.
set
(
pageNum
,
false
)
}
boxes
.
forEach
((
box
,
index
)
=>
{
drawPartialRect
(
ctx
,
box
,
1
,
scale
);
});
canvas
.
style
.
width
=
false
?
`
${
w
}
px`
:
'
100%
'
;
canvas
.
style
.
height
=
false
?
`
${
h
}
px`
:
'
100%
'
;
ctx
.
restore
();
}
!!
bboxes
?.
length
&&
drawBoxes
(
bboxes
,
scale
);
}
// init extractLayer data
if
(
type
===
'
initExtractLayerData
'
)
{
const
scale
=
0.943
/
0.7071
*
window
?.
PDFViewerApplication
?.
pdfViewer
?.
_currentScale
||
1
const
currentPageNumber
=
window
?.
PDFViewerApplication
?.
pdfViewer
?.
_currentPageNumber
||
1
window
.
pdfExtractData
=
data
;
window
.
renderExtractLayer
=
renderExtractLayer
// window.renderExtractLayer(window.pdfExtractData, currentPageNumber - 1, scale)
// use the picture view rather than outlined view
window
.
renderExtractLayer
(
window
.
pdfExtractData
,
Number
(
0
),
scale
)
window
?.
PDFViewerApplication
?.
pdfSidebar
?.
switchView
(
1
,
false
)
}
if
(
type
===
'
pageChange
'
)
{
if
(
window
.
renderExtractLayer
&&
window
.
pdfExtractData
)
{
const
scale
=
0.943
/
0.7071
*
window
?.
PDFViewerApplication
?.
pdfViewer
?.
_currentScale
||
1
const
currentPageNumber
=
data
||
0
window
.
renderExtractLayer
(
window
.
pdfExtractData
,
Number
(
0
),
scale
)
window
.
renderExtractLayer
(
window
.
pdfExtractData
,
Number
(
data
),
scale
)
}
else
if
(
!
window
.
pdfExtractData
)
{
// console.error('extract pdf render data has not been initialized')
}
}
if
(
type
===
'
title
'
)
{
const
odlPdfTitle
=
document
.
getElementById
(
"
odl-pdf-title
"
);
odlPdfTitle
.
innerText
=
data
;
}
if
(
type
===
'
setPage
'
)
{
window
?.
PDFViewerApplication
?.
eventBus
?.
dispatch
(
"
pagenumberchanged
"
,
{
value
:
data
})
}
if
(
type
===
''
)
{
}
});
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitDingbats.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixed.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixedBold.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixedBoldItalic.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitFixedItalic.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitSerif.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitSerifBold.pfb
0 → 100644
View file @
ece7f8d5
File added
projects/web/public/pdfjs-dist/web/standard_fonts/FoxitSerifBoldItalic.pfb
0 → 100644
View file @
ece7f8d5
File added
Prev
1
…
14
15
16
17
18
19
20
21
22
…
28
Next
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