我正在使用Codeigniter,我成功实现了dompdf来生成PDF文件.现在我在生成的PDF中添加页眉和页脚时遇到问题.
这是我的dompdf_helper代码:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename='', $stream=TRUE)
{
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->set_paper("A4");
if ($stream) {
$dompdf->stream($filename.".pdf",1);
} else {
return $dompdf->output();
}
}
?>
Run Code Online (Sandbox Code Playgroud)
这是我的控制器调用PDF生成:
<?php
$data['store']=$res;
$this->load->helper(array('dompdf', 'file'));
$html = $this->load->view('store/sales_pdf', $data, true);
$html.= $this->load->view('footer');
$filename="salesbill".$id;
pdf_create($html, $filename);
$data = pdf_create($html, '', false);
write_file('name', $data);
?>
Run Code Online (Sandbox Code Playgroud)
我使用此脚本获取页码,但仅在第二页退出时打印,否则将无法打印.
<script type="text/php">
if ( isset($pdf) ) {
$font = Font_Metrics::get_font("helvetica", "bold");
$pdf->page_text(500,10, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
}
</script> …Run Code Online (Sandbox Code Playgroud) 我正在使用Bootstrap 3和数据表1.9.单击数据表第一页中的锚标记时,模态打开,但在使用数据表分页后显示Bootstrap模式时出现问题.如何解决这个问题.这是我的代码
<html>
<body>
<table id=prodlist class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
</tr>
</thead>
<tbody>
<tr>
<td> <a href="http://localhost/admin/product/viewProduct/15" class="prod-view" data-target="#modal" data-toggle="modal">edit</a>
</td>
</tr>
<tr><td>
<a href="http://localhost/admin/product/viewProduct/15" class="prod-view" data-target="#modal" data-toggle="modal">edit</a>
</td></tr>
<tr><td>
<a href="http://localhost/admin/product/viewProduct/15" class="prod-view" data-target="#modal" data-toggle="modal">edit</a>
</td> </tr>
</tbody>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的数据表javascript是
$(function() {
$("#prodlist").dataTable({
"bAutoWidth": false,
"aoColumnDefs": [{
"sWidth": "5%",
"aTargets": [0],
"bSearchable": false,
"bSortable": false,
"bVisible": true
}, ]
});
});
if ($(".alert-success, .alert-error").length > 0) {
setTimeout(function() {
$(".alert-success, .alert-error").fadeOut("slow");
}, 1000);
}
$(document).ready(function(){
$(".prod-view").click(function(){ …Run Code Online (Sandbox Code Playgroud)