我正在使用DOMPDF生成PDF文件。 我想要除了最后一页以外的所有页面中的页脚(页码和页数)。 目前我有这个代码
$dompdf = new DOMPDF();
$html = ob_get_contents();
$dompdf->load_html($html);
$dompdf->render();
$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "12");
$canvas->page_text(500, 770, "Page {PAGE_NUM} - {PAGE_COUNT}", $font, 10, array(0,0,0));
$canvas->page_text(260, 770, "Canny Pack", $font, 10, array(0,0,0));
$canvas->page_text(43, 770, $date, $font, 10, array(0,0,0));
$pdf = $dompdf->output();
以上代码在所有页面中显示页脚。但我不想在最后一页页脚。
谁能告诉我怎么做?
答案 0 :(得分:2)
<div class="form-group">
@Html.LabelFor(model => model.StartDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.StartDate, new { id = "datetimepicker3", @style = "width:150px" })
@Html.ValidationMessageFor(model => model.StartDate, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EndDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.EndDate, new { id = "datetimepicker4", @style = "width:150px" })
@Html.ValidationMessageFor(model => model.EndDate, "", new { @class = "text-danger" })
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#datetimepicker3').datetimepicker({
format: 'd.m.Y H:i',
minDate:'-1969/12/31',
inline: true,
lang: 'en',
onSelect: function (date) {
var selectedDate = new Date(date);
var msecsInOneHour = 3600000;
var endDate = new Date(selectedDate.getTime() + msecsInOneHour);
$("#datetimepicker4").datepicker("option", "minDate", endDate);
}
});
$("#datetimepicker4").datepicker({
format: 'd.m.Y H:i',
inline: true,
lang: 'en'
});
});
</script>
方法在所有页面上无限制地运行。如果将page_text()
方法与text()
方法结合使用,则可以通过编程方式确定要插入文本的页面。
以下内容应该有效:
page_script()