File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const de: Strings = {
6565 muteUnmute : 'Ton Aktivieren/Deaktivieren' ,
6666 navbar : 'Navigationsleiste' ,
6767 quickMenu : 'Schnellmenü' ,
68+ printToPdf : 'Als PDF drucken...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export const en = {
6464 listPages : 'List Pages' ,
6565 muteUnmute : 'Mute / Unmute' ,
6666 navbar : 'Navigation Bar' ,
67+ printToPdf : 'Print to PDF...' ,
6768 } ,
6869
6970 dialog : {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const es: Strings = {
6565 muteUnmute : 'Activar/Desactivar Sonido' ,
6666 navbar : 'Barra de Navegación' ,
6767 quickMenu : 'Menú Rápido' ,
68+ printToPdf : 'Imprimir en PDF...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const fr: Strings = {
6565 muteUnmute : 'Activer/Désactiver le Son' ,
6666 navbar : 'Barre de Navigation' ,
6767 quickMenu : 'Menu Rapide' ,
68+ printToPdf : 'Imprimer en PDF...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const it: Strings = {
6565 muteUnmute : 'Attiva/Disattiva Audio' ,
6666 navbar : 'Barra di Navigazione' ,
6767 quickMenu : 'Menu Rapido' ,
68+ printToPdf : 'Stampa in PDF...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const ptBR: Strings = {
6565 muteUnmute : 'Ativar/Desativar Som' ,
6666 navbar : 'Barra de Navegação' ,
6767 quickMenu : 'Menu Rápido' ,
68+ printToPdf : 'Imprimir como PDF...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const ptPT: Strings = {
6565 muteUnmute : 'Ativar/Desativar Som' ,
6666 navbar : 'Barra de Navegação' ,
6767 quickMenu : 'Menu Rápido' ,
68+ printToPdf : 'Imprimir em PDF...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export const ru: Strings = {
6565 muteUnmute : 'Включить/Выключить Звук' ,
6666 navbar : 'Панель Навигации' ,
6767 quickMenu : 'Быстрое Меню' ,
68+ printToPdf : 'Печать в PDF...' ,
6869 } ,
6970
7071 dialog : {
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ class MenuService {
114114 menuItems . push ( { label : s . preferences , click : ( ) => PreferencesService . open ( ) } ) ;
115115
116116 if ( currentPageSubmenu ) {
117- const navbarPrefix = ! ! Storage . getSettings < boolean > ( Settings . SHOW_FRAME ) ? "✓ " : "" ;
117+ const navbarPrefix = Storage . getSettings < boolean > ( Settings . SHOW_FRAME ) ? '✓ ' : '' ;
118118 AppState . viewContextMenu = [
119119 { label : s . openAnonymously , click : ( ) => { FrameService . reopenAnonymously ( ) ; } } ,
120120 { label : navbarPrefix + s . navbar , click : ( ) => { FrameService . toggleNavbar ( ) ; } } ,
@@ -206,6 +206,7 @@ class MenuService {
206206 { label : s . copyUrl , click : ( ) => clipboard . writeText ( wc . getURL ( ) ) } ,
207207 { label : s . openInBrowser , click : ( ) => { shell . openExternal ( wc . getURL ( ) ) ; } } ,
208208 { label : s . createPageFromUrl , click : ( ) => { PageService . createNewPageFromCurrentUrl ( ) ; } } ,
209+ { label : s . printToPdf , click : ( ) => { ViewService . printToPdf ( ) ; } } ,
209210 { type : 'separator' } ,
210211 { label : s . openDevTools , click : ( ) => wc . openDevTools ( ) } ,
211212 { label : s . permissions , click : ( ) => PreferencesService . openPermissions ( wc . getURL ( ) ) } ,
Original file line number Diff line number Diff line change @@ -266,6 +266,23 @@ class ViewService {
266266 childWindow . loadURL ( url ) ;
267267 }
268268
269+ public async printToPdf ( view = this . getCurrentView ( ) ! ) : Promise < void > {
270+ try {
271+ const buffer = await view . webContents . printToPDF ( { printBackground : true } ) ;
272+ const title = view . webContents . getTitle ( ) . replace ( / [ / \\ ? % * : | " < > ] / g, '-' ) || 'page' ;
273+ const result = await dialog . showSaveDialog ( {
274+ title : AppState . strings . dialog . saveFile ,
275+ defaultPath : `${ title } .pdf` ,
276+ filters : [ { name : 'PDF' , extensions : [ 'pdf' ] } ] ,
277+ } ) ;
278+ if ( ! result . canceled && result . filePath ) {
279+ writeFileSync ( result . filePath , buffer ) ;
280+ }
281+ } catch ( error ) {
282+ console . error ( 'Error printing to PDF:' , error ) ;
283+ }
284+ }
285+
269286 public async openQuickAction ( urlTemplate : string , view = this . getCurrentView ( ) ! ) : Promise < void > {
270287 const text = await this . getSelectedText ( view ) ;
271288 const locale = AppState . language ;
You can’t perform that action at this time.
0 commit comments