【问题标题】:Print PDF file to printer on the network in Laravel在 Laravel 中将 PDF 文件打印到网络上的打印机
【发布时间】:2020-12-15 10:25:28
【问题描述】:

我正在使用 Laravel 开发内部网。

我生成了一个 PDF,并希望在网络上的打印机上自动打印此 PDF。 生成 PDF 不是问题,但我找不到打印它的方法。 我们使用的是 IBM 的 Power Server,所以 laravel-printing 包无法工作。

有人有什么想法吗?

【问题讨论】:

    标签: php laravel printing


    【解决方案1】:

    使用 javascript 打印它。

    <script>
    function PrintElem(elem)
    {
        var mywindow = window.open('', 'PRINT', 'height=400,width=600');
    
        mywindow.document.write('<html><head><title>' + document.title  + '</title>');
        mywindow.document.write('</head><body >');
        mywindow.document.write('<h1>' + document.title  + '</h1>');
        mywindow.document.write(document.getElementById(elem).innerHTML);
        mywindow.document.write('</body></html>');
    
        mywindow.document.close(); // necessary for IE >= 10
        mywindow.focus(); // necessary for IE >= 10*/
    
        mywindow.print();
        mywindow.close();
    
        return true;
    }
    </script>
    

    通过单击按钮或其他方式调用该函数(因为您在生成 pdf 后调用该函数)

    【讨论】:

    • 我们不希望用户看到任何有关打印的信息。 pdf在后端生成,需要打印到打印机
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    相关资源
    最近更新 更多