简体   繁体   中英

DomPDF display data table except last page

I am working to produce pdf in codeigniter data. 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. 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? 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.

the way you are loading in pdf is as a string and is not rendering html code. For rendering as html code you must put it inside loadHtml()

$pageText must be inside loadHtml() .

You should keep the html codes inside loadHtml() .
Or you can make a separate file using html for making pdf. you can check out documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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