KoolReport's Forum

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

Export to pdf: Page Number not showing #2594

Open FIMM opened this topic on on Feb 24, 2022 - 11 comments

FIMM commented on Feb 24, 2022

Laravel koolreport. Export to pdf , Page number not showing.

  <div class="page-footer" style='height:30px'>
          <hr style=" border: 3px solid #0a0a38;border-radius: 3px;"/>
               <span> Page {pageNum}/{numPages}</span>
        </div>
->pdf(array(
                "format"=>"A4",
                "orientation"=>"portrait",
                "zoom"=>0.5,
                "dpi"=>72,
               // "margin"=>"1in",
                "margin"=>array(
                    "top"=>"0.5in",
                    "bottom"=>"0.5in",
                    "left"=>"1in",
                    "right"=>"1in",
                ),
                "header"=>array("height"=>"300px","contents"=>"this is header"),
                "footer"=>array("height"=>"300px","display"=>"none","contents"=>"this is header"),
                "headerCallback" => "function(headerContent, pageNum, numPages){
                    if (pageNum == 1) return ''; 
                    return 'This is a header' || headerContent;
                }",
                "footerCallback" => "function(footerContent, pageNum, numPages){
                    if (pageNum == numPages) return ''; 
                    return 'This is a footer' || footerContent;
                }",
            ))

In this option header and footer not working for me. Please help me. Thanks in advance

Sebastian Morales commented on Feb 24, 2022

Pls remove the "footerCallback" property in your pdf() method because it changes the content of your footer to no longer containing {pageNum} or {numPages} placeholder. Rgds,

FIMM commented on Feb 24, 2022

I remove that code but still header and footer not working. We buy pro package but it is not working well. Please help me.

         $report = new  CasUtcReport;
         $report->run()
        ->export('CasUtcReportPdf')
         ->settings(array(
            "useLocalTempFolder"=>true,
            "autoDeleteLocalTempFile"=>true,
            "phantomjs"=>"/usr/bin/phantomjs",
           // "resourceWaiting"=>2000,
            "serverLocalAddress" => "localhost"
        ))
        ->pdf(array(
            "format"=>"A4",
            "orientation"=>"portrait",
            "zoom"=>0.5,
            "dpi"=>72,
           // "margin"=>"1in",
            "margin"=>array(
                "top"=>"0.5in",
                "bottom"=>"0.5in",
                "left"=>"1in",
                "right"=>"1in",
            ),
            "header"=>array("height"=>"300px","contents"=>"this is header"),
            "footer"=>array("height"=>"300px","contents"=>"this is footer"),
        ))
        ->toBrowser("report.pdf",true);

In view.php I put both but not working any one

     <footer style='height:30px'>
        <span>Page {pageNum}/{numPages}</span>
    </footer>
     <div class="page-footer" style='height:30px;float:right;width:100%;'>
      <hr style=" border: 3px solid #0a0a38;border-radius: 3px;"/>
           <span style='float:right;'> Page {pageNum}/{numPages}</span>
    </div>
Sebastian Morales commented on Feb 24, 2022

Did you put these "page-footer" and "page-header" inside your PDF view file instead of the web view file? Pls try putting this in your PDF view file and let us know the result of the output PDF's footer:

<!-- MyReportPDF.view.php -->
<html>
    <body style="margin: 1in">
        <div class='page-header' style='height:30px'>
            <span>Page {pageNum}/{numPages}</span>
        </div>

        ...
        ...

        <div class='page-footer' style='height:30px'>
            <span>Page {pageNum}/{numPages}</span>
        </div>
    </body>
</html>
FIMM commented on Feb 24, 2022

Yes I put this code in my pdf.view.php BUT still same

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

Inside this div nothing to display.

Sebastian Morales commented on Feb 24, 2022

Pls try to run our header/footer export example on your machine:

https://www.koolreport.com/examples/reports/export/header_footer/

Check if page number is in PDF footer. Tks,

FIMM commented on Feb 24, 2022

I create Another fresh laravel project . With your code. header and footer not working for me. Inside those div nothing to display. Please suggest me what should I do.

    <div class="page-header" style="text-align:right"><i>Sakila Rental Report</i></div>
    <div class="page-footer" style="text-align:right">{pageNum}</div>
Sebastian Morales commented on Feb 24, 2022

Pls post screenshots of your output PDF with no page num in footer. Also let us know which operating system your server uses and how you install Phantomjs for it. Tks,

FIMM commented on Feb 24, 2022

My Operating System is Ubuntu.

sudo apt install phantomjs

Sebastian Morales commented on Feb 24, 2022

Pls try to use the binary file from this page:

https://phantomjs.org/download.html

FIMM commented on Feb 24, 2022

Thanks this binary file worked for header and footer. Now page number is shown. But in PDF CSS class not working. For example in Datatables I used this class "table table-bordered table-striped" but it doesn't affect anything.. Please suggest me for CSS. Thanks in advance

Sebastian Morales commented on Feb 28, 2022

Would you pls show us your table create code and did you use Bootstrap trait or load Bootstrap css yourself in your pdf view? Tks,

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
solved

None