KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to print page number like 2 of 10 in PDF #2998

Open AhmedHaroon opened this topic on on Feb 24, 2023 - 3 comments

AhmedHaroon commented on Feb 24, 2023

how i can add page numbers on every page in generated PDF like below:

Page 2 of 10

i copied a code below when trying to search here but it is showing only 'pageNum' as it is.

<div class="page-footer" style="text-align:right">{pageNum}</div>

please help, what i have missed or doing wrong here?

the complete code file for OrderSummaryPdf.view.php screenshot of PDF is below this code

<?php
    use \koolreport\widgets\koolphp\Table;
?>
<html>
    <head>
        <style>
            .table {
                font-family: Arial, Helvetica, sans-serif;
                border-collapse: collapse;
                width: 100%;
            }

            .table td, .table th {
                border: 1px solid #ddd;
                padding: 8px;
            }

            .table tr:nth-child(even){
                background-color: #f2f2f2;
            }

           .table tr:hover {
                background-color: #ddd;
            }

            .table th {
                padding-top: 12px;
                padding-bottom: 12px;
                text-align: left;
                background: #1e3d73;
                color: white;
            }
        </style>
    </head>
    <body style="margin:0.5in 1in 0.5in 1in">
        <div class="text-center">
            <center><h1>Order Summary</h1></center>
        </div>
        <?php
            Table::create(array(
                "dataStore"=>$this->dataStore('result'),
                "showFooter"=>true,
                "columns"=>array(

                    "order_date"=>array(
                        "cssStyle"=>"text-align:center",
                        "label"=>"Order Date",
                        "footerText"=>"<b>Total</b>"
                    ),
                    "no_of_orders"=>array(
                        "cssStyle"=>"text-align:right",
                        "label"=>"No. of Orders",
                        "type"=>"number",
                        "footer"=>"sum",
                        "footerText"=>"<b>@value</b>"
                    ),
                    "rider_charges"=>array(
                        "cssStyle"=>"text-align:right",
                        "label"=>"DC",
                        "type"=>"number",
                        "footer"=>"sum",
                        "footerText"=>"<b>@value</b>"
                    ),
                    "order_total"=>array(
                        "cssStyle"=>"text-align:right",
                        "label"=>"GMV",
                        "type"=>"number",
                        "footer"=>"sum",
                        "footerText"=>"<b>@value</b>"
                    ),
                ),
                "cssClass"=>array(
                    "table"=>"table table-hover table-bordered"
                )
            ));
        ?>
        <!-- <div class="page-footer" style="text-align:right">{pageNum}</div> -->
        <footer style='height:30px'>
            <span>Page {pageNum} of {numPages}</span>
        </footer>
    </body>
</html>

Screenshot:

regards

KoolReport commented on Feb 24, 2023

It should be:

        <div class='page-footer' style='height:30px'>
            <span>Page {pageNum} of {numPages}</span>
        </div>

The div with class "page-footer" is important as export package will look for that to make it footer.

AhmedHaroon commented on Feb 24, 2023

thanks @KoolReport, this isn't working, already mentioned in my OP, before complete code of my Pdf.view.php file. and also commented out in complete code.

also want to know about how to have Column Headers on every page as it is showing only on first page. ( may i have to create new topic/thread for this? )

regards

Sebastian Morales commented on Feb 27, 2023

Did you use the Export or CloudExport package?

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None