blob: e7419428782134f8c918630f8c0c13ccd1361b44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
const autoPrintCode = `
<script>
document.addEventListener("DOMContentLoaded", () => {
Promise.all(Array.from(document.images)
.filter(img => !img.complete)
.map(img => new Promise(resolve => {
img.onload = img.onerror = resolve;
}))).then(() => {
window.print();
window.close();
});
});
</script>
`;
export const downloadPDF = (content: string) => {
const tab = window.open("about:blank", "_blank");
if (tab) {
tab.document.write(content + autoPrintCode);
tab.document.close();
}
};
|