douxian7808 2018-11-26 14:08
浏览 2300

ElectronJs无声打印PDF

I have a simple electronJS application which interacts with my laravel backend server. The backend server produces a PDF to a certain size such as 86mm x 54mm and streams the PDF to my electronJS application for it to print silently to the default printer. Currently in my Electron application I get the popup to save the streamed PDF to the machine rather than it print silently.

My electronJs code handling the print method.

const printWindow = new BrowserWindow({ show: false });
printWindow.loadURL('http://localhost:8000/pass');
printWindow.webContents.on('did-finish-load', () => {
   printWindow.print({ silent: true, deviceName: '' });
});

My laravel code for returning the PDF after hitting a route.

Route::get('/pdf', function () {
    $pdf = \PDF::loadView('pdf.layout');
    $pdf->setPaper([0, 0, 175.748, 243.78], 'landscape');
    return $pdf->stream('pdf.pdf');
});

I expected the pdf to print to the default printer however this produces a popup to download the PDF file?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题