async printBkb() {
const bkb = await fetch("./pdfPrint/备考表.pdf").then((res) =>
res.arrayBuffer()
);
const blob = new Blob([bkb], { type: "application/pdf" });
var date = new Date().getTime();
var ifr = document.createElement("iframe");
ifr.style.border = "none";
ifr.style.display = "block"; // 确保 iframe 可见
ifr.style.pageBreakBefore = "always";
ifr.setAttribute("id", "printPdf" + date);
ifr.setAttribute("name", "printPdf" + date);
ifr.src = window.URL.createObjectURL(blob);
document.body.appendChild(ifr);
var ordonnance = document.getElementById("printPdf" + date).contentWindow;
// 增加等待时间,确保 PDF 文件加载完毕
setTimeout(() => {
ordonnance.print();
window.URL.revokeObjectURL(ifr.src); // 释放URL 对象
}, 1000); // 适当增加时间
},

3269

被折叠的 条评论
为什么被折叠?



