在PHP中使用mpdf,在新选项卡中打开打印对话框 [英] Using mpdf in PHP, open print dialog box in a new tab
问题描述
我正在使用mPDF库在PHP中创建报告。直到现在输出被保存为pdf文件,我需要通过打开自动下载的文件手动打印出来。
我需要的是我点击后立即我的PHP网页上的打印按钮,mPDF应创建输出并立即使用默认打印机打印文档。我甚至不需要任何中间对话框,可以再次获得打印确认。简单地说,点击基于PHP的网页按钮应该将打印命令发送到默认打印机。
以下是我的代码:
include( \ mpdf\mpdf.php 跨度>);
$ mpdf = new mPDF(' ',' A4');
$ mpdf-> WriteHTML($ a);
$ mpdf->输出(' r.pdf',' D');
我还能做些什么来实现我的需求?
我尝试过的事情:
我尝试过以下代码:
include( \ mpdf\mpdf.php);
$ mpdf = new mPDF(' ',' A4');
$ mpdf-> WriteHTML($ a);
$ mpdf-> SetJS(' this.print();');
$ mpdf->输出();
此解决方案出现两个问题:
1.它仍会打开一个打印确认对话框。
2.它打开当前标签中的打印预览和对话框,这意味着点击打印在单击打印之前,我无法获得与之相同的界面。为此,我必须单击浏览器上的后退按钮,这不是一个好的解决方案。
mpdf = new mPDF(' ',' A4' 跨度>);
mpdf->的WriteHTML(
一个);
I am creating a report in PHP using mPDF Library. Till now the output is saved as a pdf file which I need to print out manually by opening the auto downloaded file.
What I need is as soon as I click on Print button on my PHP Web page, mPDF should create the output and immediately print the document using default printer. I even donot need any intermediate dialog box that would again get a confirmation to print. Simply, clicking on PHP based web page button should send the print command to the default printer.
Below is my code:
include("\mpdf\mpdf.php");
$mpdf=new mPDF('','A4');
$mpdf->WriteHTML($a);
$mpdf->Output('r.pdf', 'D');
What else I can do to achieve what I need?
What I have tried:
I have tried the following code:
include("\mpdf\mpdf.php");
$mpdf=new mPDF('','A4');
$mpdf->WriteHTML($a);
$mpdf->SetJS('this.print();');
$mpdf->Output();
This solution comes up with two problems:
1. It still opens a dialog for print confirmation.
2. It opens the print preview and the dialog box in my current tab which means that on clicking print, I cannot get the same interface on which I was working before clicking Print. For that, I have to click on back button on the browser which is not a good solution.
mpdf=new mPDF('','A4');
mpdf->WriteHTML(
a);
这篇关于在PHP中使用mpdf,在新选项卡中打开打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!