Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: wait 1s for math to render on pdf print

Abdullah Attabb6d9f604bf9
diff --git a/apps/web/src/common/export.ts b/apps/web/src/common/export.ts
index c6b9e95a7..b84a1bb4c 100644
--- a/apps/web/src/common/export.ts
+++ b/apps/web/src/common/export.ts
@@ -41,12 +41,21 @@ export async function exportToPDF(
iframe.style.width = "0";
iframe.style.height = "0";
iframe.style.border = "0";
+ iframe.loading = "eager";
- iframe.onload = () => {
+ iframe.onload = async () => {
if (!iframe.contentWindow) return;
if (iframe.contentDocument) iframe.contentDocument.title = title;
iframe.contentWindow.onbeforeunload = () => closePrint(false);
iframe.contentWindow.onafterprint = () => closePrint(true);
+
+ if (
+ iframe.contentDocument &&
+ !!iframe.contentDocument.querySelector(".math-block,.math-inline")
+ ) {
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ }
+
iframe.contentWindow.print();
};