blob: 67540a6013e2ad258f17167aecfde744c0638fc9 (
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, filename: string = "banglarbhumi.pdf") => {
const tab = window.open("about:blank", "_blank");
if (tab) {
tab.document.write(content + autoPrintCode);
tab.document.close();
}
};
|