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