gpt4 book ai didi

php - 更改 mPDF 上的页面大小并使浏览器自动打印显示的 PDF 文件

转载 作者:行者123 更新时间:2023-11-28 12:09:41 25 4
gpt4 key购买 nike

我正在使用 mPDF ( http://mpdf.bpm1.com ) 创建 pdf 收据,但目前它们仅显示在完整的 A4 页面上。

我想将它们调整到合理的大小,因为我们使用的是 epson tm-t88iv。这是我面临的第一个困境。

我遇到的第二个问题涉及在连接的打印机上调用自动打印。

我想在处理表单时执行此操作(在同一页面上)。

但我不确定如何将其实现到我现在拥有的代码中:

  <?php 

// post

$id = $_GET['id'];
$user = $_GET['user'];
$week = $_GET['week'];
$pRent = $_GET['pRent'];
$rentPaid = $_GET['rentPaid'];
$result = $_GET['result'];
$pDate = date("d/m/Y");

$html = '

<style>
@page {
margin-top: 20px;
margin-left: 20px;
}
</style>

<div style="text-align:center; font-family: Arial, Helvetica, sans-serif;">
<div style="border: 0px; padding: 0px; width: 175px; text-align:center;">
<img src="resources/speedline.png" width="161" height="58" />
<p style="font-weight: bold;" align="center">
DRIVER '.$id.' RECEIPT</p>
<p style="font-size: 12px; font-family: Arial, Helvetica, sans-serif;">'.$week.'</p>
<span style="font-size: 10px;">PROCESSED BY '.$user.'</span><p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td align="left" style="font-weight: bold; font-family: Arial, Helvetica, sans-serif;">DATE PAID</td>
<td style="font-size: 12px; font-family: Arial, Helvetica, sans-serif;" align="right">'.$pDate.'</td>
</tr>
<tr>
<td align="left"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="left" style="font-weight: bold; font-family: Arial, Helvetica, sans-serif;">TOTAL RENT</td>
<td style="font-size: 12px; font-family: Arial, Helvetica, sans-serif;" align="right">£'.$pRent.'</td>
</tr>
<tr>
<td align="left" style="font-weight: bold; font-family: Arial, Helvetica, sans-serif;">RENT PAID</td>
<td style="font-size: 12px; font-family: Arial, Helvetica, sans-serif;" align="right">£'.$rentPaid.'</td>
</tr>
<tr>
<td align="left">&nbsp;</td>
<td></td>
</tr>
<tr>
<td align="left" style="font-weight: bold; font-family: Arial, Helvetica, sans-serif;">REMAINING</td>
<td align="right" style="font-family: Arial, Helvetica, sans-serif;">£'.$result.'</td>
</tr>
</table>
<br />
<span style="font-size:8px">THANK YOU FOR YOUR PAYMENT. PLEASE KEEP THIS RECEIPT FOR FUTURE REFERENCE. YOU WILL BE ASKED TO PRESENT IT AS EVIDENCE OF PAYMENT MADE.</span>
</div>';

//==============================================================
//==============================================================
//==============================================================
include("mpdf/mpdf.php");
$mpdf=new mPDF('UTF-8-s','');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
//==============================================================
//==============================================================
//==============================================================
//==============================================================
//==============================================================
?>

最佳答案

尝试:$mpdf = new mPDF('', '字母', 0, '', 12.7, 12.7, 14, 12.7, 8, 8);

并调整末尾的值以获得所需的边距。查看their documentation

抱歉,不确定自动打印,但有一些信息 here

关于php - 更改 mPDF 上的页面大小并使浏览器自动打印显示的 PDF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4332016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com