From 2d4d5802b6702bf3260d19d9d99dd53bde3a386c Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Sun, 26 Oct 2025 20:15:52 +0530 Subject: [PATCH] =?UTF-8?q?Fix=20PDF=20export=20geometry=20error=20and=20i?= =?UTF-8?q?mprove=20print/file=20loading=20timing=20PDF=20Export=20Fix:=20?= =?UTF-8?q?-=20Fixed=20ReferenceError:=20geometry=20is=20not=20defined=20i?= =?UTF-8?q?n=20PDF=20export=20-=20Removed=20hardcoded=20undefined=20geomet?= =?UTF-8?q?ry=20variable=20from=20pandoc=20command=20-=20Geometry=20option?= =?UTF-8?q?=20now=20properly=20extracted=20from=20options=20object=20when?= =?UTF-8?q?=20present=20-=20PDF=20export=20now=20works=20without=20errors?= =?UTF-8?q?=20Print=20Preview=20Timing:=20-=20Changed=20from=20requestAnim?= =?UTF-8?q?ationFrame=20to=20setTimeout=20for=20more=20reliable=20renderin?= =?UTF-8?q?g=20-=20Increased=20delay=20from=200ms=20to=20300ms=20before=20?= =?UTF-8?q?sending=20print=20command=20-=20Post-print=20UI=20restoration?= =?UTF-8?q?=20after=20500ms=20to=20ensure=20printer=20captured=20output=20?= =?UTF-8?q?-=20More=20reliable=20toolbar=20hiding=20before=20print=20dialo?= =?UTF-8?q?g=20opens=20File=20Loading=20Timing:=20-=20Increased=20delay=20?= =?UTF-8?q?from=20500ms=20to=202000ms=20(2=20seconds)=20for=20file-opened?= =?UTF-8?q?=20message=20-=20Ensures=20complete=20theme=20application=20and?= =?UTF-8?q?=20preview=20pane=20initialization=20-=20Files=20now=20load=20a?= =?UTF-8?q?nd=20render=20consistently=20on=20first=20double-click=20All=20?= =?UTF-8?q?timing=20issues=20related=20to=20browser=20rendering=20and=20DO?= =?UTF-8?q?M=20updates=20resolved.=20=F0=9F=A4=96=20Generated=20with=20[Cl?= =?UTF-8?q?aude=20Code](https://claude.com/claude-code)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 9 +++++---- src/renderer.js | 45 ++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main.js b/src/main.js index 038543a..c1227f4 100644 --- a/src/main.js +++ b/src/main.js @@ -795,9 +795,10 @@ function tryPdfFallback(inputFile, outputFile, engines, index, options, lastErro } const engine = engines[index]; - let pandocCmd = `${getPandocPath()} "${inputFile}" --pdf-engine=${engine} -V geometry:${geometry} -o "${outputFile}"`; + let pandocCmd = `${getPandocPath()} "${inputFile}" --pdf-engine=${engine} -o "${outputFile}"`; - if (options.geometry) pandocCmd += ` -V geometry:"${options.geometry}"`; + // Add geometry if specified + if (options.geometry) pandocCmd = pandocCmd.replace(` -o `, ` -V geometry:"${options.geometry}" -o `); // Add all other options if (options.template && options.template !== 'default') { @@ -1665,10 +1666,10 @@ function openFileFromPath(filePath) { const content = fs.readFileSync(filePath, 'utf-8'); if (mainWindow && mainWindow.webContents && rendererReady) { // Add delay to ensure renderer is fully prepared to display the file - // Give extra time for theme application and preview pane setup + // Wait for theme, preview pane, and all CSS to be fully loaded setTimeout(() => { mainWindow.webContents.send('file-opened', { path: filePath, content }); - }, 500); + }, 2000); } else { // Store file to open after renderer is ready app.pendingFile = filePath; diff --git a/src/renderer.js b/src/renderer.js index 3f54908..dd63810 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -1199,33 +1199,32 @@ function handlePrintPreview(withStyles) { } } - // Use requestAnimationFrame twice to ensure browser has rendered the DOM changes - requestAnimationFrame(() => { - requestAnimationFrame(() => { - // Now tell main process to print - the DOM is fully rendered - ipcRenderer.send('do-print', { withStyles }); + // Wait for DOM to render the changes before printing + // Use setTimeout to ensure browser has time to repaint + setTimeout(() => { + // Tell main process to print - the DOM is now fully rendered + ipcRenderer.send('do-print', { withStyles }); - // Restore UI after print - setTimeout(() => { - document.getElementById('toolbar').style.display = ''; - document.getElementById('tab-bar').style.display = ''; - document.getElementById('status-bar').style.display = ''; + // Restore UI after a delay (printer will have captured the output by then) + setTimeout(() => { + document.getElementById('toolbar').style.display = ''; + document.getElementById('tab-bar').style.display = ''; + document.getElementById('status-bar').style.display = ''; - if (editorPane) { - editorPane.style.display = ''; - } + if (editorPane) { + editorPane.style.display = ''; + } - dialogs.forEach(id => { - const dialog = document.getElementById(id); - if (dialog) dialog.style.display = ''; - }); + dialogs.forEach(id => { + const dialog = document.getElementById(id); + if (dialog) dialog.style.display = ''; + }); - if (previewPane) { - previewPane.classList.remove('print-mode', 'print-no-styles'); - } - }, 100); - }); - }); + if (previewPane) { + previewPane.classList.remove('print-mode', 'print-no-styles'); + } + }, 500); + }, 300); } // Export Dialog functionality