Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rongtong-pc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
融通安全管理系统
rongtong-pc
Commits
1a476940
Commit
1a476940
authored
Jul 24, 2023
by
yf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改四色图导出
parent
ee16aa03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
13 deletions
+5
-13
src/views/risk/drawCanvas/index.vue
src/views/risk/drawCanvas/index.vue
+5
-13
No files found.
src/views/risk/drawCanvas/index.vue
View file @
1a476940
...
...
@@ -121,19 +121,10 @@ export default {
var
title
=
"
四色图
"
;
// html2Canvas(document.querySelector('#pdfDom'), { //这是在界面上设置一个id
//只下载id为pdfDom的内容
html2Canvas
(
document
.
querySelector
(
"
#gridView
"
),
{
//body是下载整个界面
useCORS
:
true
,
//是否尝试使用CORS从服务器加载图像
allowTaint
:
true
,
dpi
:
300
,
//解决生产图片模糊
// width: 490, //canvas宽度
// height: 240, //canvas高度
// x: 0, //x坐标
// y: 0, //y坐标
async
:
false
,
//是否异步解析和呈现元素
foreignObjectRendering
:
true
,
//是否在浏览器支持的情况下使用ForeignObject渲染
}).
then
(
function
(
canvas
)
{
console
.
log
(
canvas
);
html2Canvas
(
document
.
querySelector
(
"
#gridView
"
),
{}).
then
(
function
(
canvas
)
{
console
.
log
(
canvas
.
width
,
canvas
.
height
);
let
contentWidth
=
canvas
.
width
;
let
contentHeight
=
canvas
.
height
;
let
pageHeight
=
(
contentWidth
/
592.28
)
*
841.89
;
// 一页pdf显示html页面生成的canvas高度;
...
...
@@ -144,6 +135,7 @@ export default {
let
imgHeight
=
(
592.28
/
contentWidth
)
*
contentHeight
;
let
pageData
=
canvas
.
toDataURL
(
"
image/jpeg
"
,
1.0
);
let
PDF
=
new
JsPDF
(
""
,
"
pt
"
,
"
a4
"
);
console
.
log
(
pageData
,
"
111
"
);
// 有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
//当内容未超过pdf一页显示的范围,无需分页
if
(
leftHeight
<
pageHeight
)
{
...
...
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