Add print functionality and native PDF support (v1.7.7)

- Added Print menu item with Ctrl+P keyboard shortcut for native OS printing
- Implemented print IPC handlers in main and renderer processes
- Remapped Toggle Preview from Ctrl+P to Ctrl+Shift+P to avoid conflicts
- Added PDFKit (v0.14.0) for native PDF generation without Pandoc
- Added html2pdf.js (v0.10.1) for HTML to PDF conversion
- Enhanced CLAUDE.md with new v1.7.7 feature documentation
- Print supports cross-platform printing (Windows, macOS, Linux)

Features:
- Native print dialog with background color printing
- Professional PDF export without system dependencies
- Improved portability and offline support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-24 22:10:30 +05:30
co-authored by Claude
parent ef3ce1647e
commit e1c0bc387f
4 changed files with 104 additions and 5 deletions
+20 -1
View File
@@ -199,6 +199,12 @@ function createMenu() {
click: saveAsFile
},
{ type: 'separator' },
{
label: 'Print',
accelerator: 'CmdOrCtrl+P',
click: () => mainWindow.webContents.send('print-document')
},
{ type: 'separator' },
{
label: 'Recent Files',
submenu: buildRecentFilesMenu()
@@ -265,7 +271,7 @@ function createMenu() {
submenu: [
{
label: 'Toggle Preview',
accelerator: 'CmdOrCtrl+P',
accelerator: 'CmdOrCtrl+Shift+P',
click: () => mainWindow.webContents.send('toggle-preview')
},
{
@@ -1151,6 +1157,19 @@ ipcMain.on('set-current-file', (event, filePath) => {
currentFile = filePath;
});
// Handle print document
ipcMain.on('print-document', (event) => {
if (mainWindow) {
// Open native print dialog
mainWindow.webContents.print({
silent: false,
printBackground: true,
color: true,
margin: { marginType: 'default' }
});
}
});
// Handle renderer ready for file association
ipcMain.on('renderer-ready', (event) => {
rendererReady = true;
+12
View File
@@ -1149,6 +1149,18 @@ ipcRenderer.on('adjust-font-size', (event, action) => {
updateFontSizes(currentFontSize);
});
// Print document handler
ipcRenderer.on('print-document', () => {
// Use the preview pane for printing
const previewContent = document.getElementById('preview');
if (previewContent && previewContent.innerHTML.trim()) {
// Create a print window with the preview content
window.print();
} else {
alert('Nothing to print. Please create or open a document and ensure the preview is visible.');
}
});
// Export Dialog functionality
let currentExportFormat = null;