You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
klhis/hcemr_new/printPage2.html

46 lines
1.1 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let params = JSON.parse(localStorage.getItem('params'))
params.urlList.forEach((url, index) => {
getBase64(url, cv => {
console.log(cv)
// 打印
// window.print()
})
})
window.print()
// 接收canvas的base64编码,赋给img.src, 将img剪切到新的canvas上
function getBase64(url, cb) {
let Img = new Image()
Img.src = url;
Img.onload = function() {
let canvas = document.createElement('canvas');
let ctx = canvas.getContext('2d')
const { urlList, width, height, pageNum } = params; // 多页参数
// const { dataurl, width, height } = params; // 单页参数
canvas.width = width;
canvas.height = height; // 单页的高
ctx.drawImage(Img,0,0)
document.body.appendChild(canvas)
// cb && cb(canvas)
}
}
</script>
</body>
</html>