admin管理员组文章数量:1287168
I am using mPDF () to create pdf receipts, but at the moment they only display on a full A4 page.
I would like to resize them down to a reasonable size because we are using a epson tm-t88iv. This is the first dilemma I have.
The second problem I have involves invoking auto print on the printer attached.
I would like to do this when the form is processed (on the same page).
But I'm not sure how to implement this into the code I have right now:
<?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> </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"> </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;
//==============================================================
//==============================================================
//==============================================================
//==============================================================
//==============================================================
?>
I am using mPDF (http://mpdf.bpm1.) to create pdf receipts, but at the moment they only display on a full A4 page.
I would like to resize them down to a reasonable size because we are using a epson tm-t88iv. This is the first dilemma I have.
The second problem I have involves invoking auto print on the printer attached.
I would like to do this when the form is processed (on the same page).
But I'm not sure how to implement this into the code I have right now:
<?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> </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"> </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;
//==============================================================
//==============================================================
//==============================================================
//==============================================================
//==============================================================
?>
Share
Improve this question
edited Jun 4, 2016 at 15:30
halfer
20.5k19 gold badges108 silver badges202 bronze badges
asked Dec 2, 2010 at 5:33
methuselahmethuselah
13.2k52 gold badges176 silver badges332 bronze badges
2 Answers
Reset to default 7Try: $mpdf = new mPDF('', 'Letter', 0, '', 12.7, 12.7, 14, 12.7, 8, 8);
and adjust the values at the end for the margins you want. Check out their documentation
Sorry, not sure about auto printing, but there is some info here
You can custom the receipt with CSS like this
@media print {
@page {
sheet-size: 76mm 210mm;
}
}
本文标签: phpChanging page size on mPDF and getting browser to auto print PDF file on displayStack Overflow
版权声明:本文标题:php - Changing page size on mPDF and getting browser to auto print PDF file on display - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741249098a2365457.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论