简体   繁体   English

DomPDF显示除最后一页之外的数据表

[英]DomPDF display data table except last page

I am working to produce pdf in codeigniter data. 我正在努力在codeigniter数据中生成pdf。 All code runs perfectly, it's just that I have a problem when doing a condition for the last page, the question is simple, I have data in table form and I want to display it for the entire page except for the last page. 所有代码运行完美,只是我在为最后一页做条件时遇到问题,问题很简单,我有表格形式的数据,我想在除最后一页之外的整个页面显示它。

if ( isset($pdf) ) { 
        $pdf->page_script('
        if ($PAGE_NUM != $PAGE_COUNT) {
        $font = $fontMetrics->get_font("Arial, Helvetica, sans-serif", "normal");
        $size = 12;
        $pageText = "Page " . $PAGE_NUM . " of " . $PAGE_COUNT;
        $y = 15;
        $x = 520;
        $pdf->text($x, $y, $pageText, $font, $size);
    } 
    ');
}

i'm tying to change $pageText = "My string text" and this is working fine, but I got problem when I combine with html table. 我想改变$pageText = "My string text" ,这工作正常,但是当我与html表结合时,我遇到了问题。 So in my case I change $pageText to $pageText = "<table><tr><td>My content here</td></tr></table>" but the results is <table><tr><td>My content here</td></tr></table> this should be a table, anyone can help me? 所以在我的情况下,我将$ pageText更改为$pageText = "<table><tr><td>My content here</td></tr></table>"但结果是<table><tr><td>My content here</td></tr></table>这应该是一张桌子,有人可以帮帮我吗? why the results is still string? 为什么结果还是字符串? and wont generate to be a table? 而不会生成一张桌子?

fyi, the code that I attach is running perfectly to display a page, it's just that I want to modify it so that it displays a table. fyi,我附加的代码完美地运行以显示页面,只是我想修改它以便它显示一个表。

the way you are loading in pdf is as a string and is not rendering html code. 你在pdf中加载的方式是一个字符串,而不是渲染HTML代码。 For rendering as html code you must put it inside loadHtml() 要呈现为HTML代码,您必须将其放在loadHtml()中

$pageText must be inside loadHtml() . $ pageText必须在loadHtml()中

You should keep the html codes inside loadHtml() . 你应该将html代码保存在loadHtml()中
Or you can make a separate file using html for making pdf. 或者你可以使用html创建一个单独的文件来制作pdf。 you can check out documentation 你可以查看文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM