Printing 如何将PDF输出发送到浏览器打印选项(CTRL+;P)
我正在使用TCPDF库生成一些报告,我想发送PDF文件到浏览器的打印选项,只要按CTRL+p,我就需要它,因为它是slip。 我使用了输出的所有参数,但它直接下载文件Printing 如何将PDF输出发送到浏览器打印选项(CTRL+;P),printing,tcpdf,Printing,Tcpdf,我正在使用TCPDF库生成一些报告,我想发送PDF文件到浏览器的打印选项,只要按CTRL+p,我就需要它,因为它是slip。 我使用了输出的所有参数,但它直接下载文件 $pdf->Output('slip.pdf', 'I'); 我还放置了I的F、D、S、E、FI和FD instate,但它不起作用。我还使用了标题 header('Content-Type: application/pdf'); $pdf->Output('example_001.pdf', 'FD'); 但它同
$pdf->Output('slip.pdf', 'I');
我还放置了I的F、D、S、E、FI和FD instate,但它不起作用。我还使用了标题
header('Content-Type: application/pdf');
$pdf->Output('example_001.pdf', 'FD');
但它同样不起作用。有解决办法吗?求你了 您尝试执行的操作不符合TCPDF API的规范
我相信您需要使用JavaScript以您所建议的方式实现此功能。您需要类似以下示例的内容。您需要截取打印请求(页面加载时自动打印、单击打印按钮等),然后调用printTrigger函数
<html>
<head>
<title>Print PDF</title>
<script>
function printTrigger(elementId) {
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
</script>
</head>
<body>
<iframe id="iFramePdf" src="http://pdfurl.com/sample.pdf"></iframe>
...
</body>
</html>
打印PDF
函数printTrigger(elementId){
var getMyFrame=document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
...
添加
$pdf->IncludeJS(“print();”)代码>
就在$pdf->Output…添加$pdf->IncludeJS(“print();”)之前;就在$pdf->输出之前。。。
这对我很有用。但我不知道javascriptsimple,smart解决方案。节省了我的时间:)你是说$pdf->Output('slip.pdf',I');或$pdf->Output('slip.pdf',F')@Jarla在$pdf->Output之前你是说$pdf->Output('slip.pdf',I');或$pdf->Output('slip.pdf',F');