KoolReport's Forum

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

Regarding first page of PDF Header Footer skipping #3057

Open Lawrbit opened this topic on on May 24 - 3 comments

Lawrbit commented on May 24

Hi Team,

We are trying to create a multi-page report into PDF with the help of an export package and trying to design the first page of the PDF as a cover page by skipping the header and footer from the first page and it's working fine.

But header and footer spacing remains the same on top and bottom how to remove that?

Please check the attached screenshot.

Sebastian Morales commented on May 25

If you use Export package, pls try setting custom headers and footers with call back:

    //headerCallback and footerCallback could be js function that return header and footer content based on current page (pageNum), total number of page (numPages) and header/footer content set by pdf option or page-header, page-footer tags
    "headerCallback" => "function(headerContent, pageNum, numPages){
        if (pageNum == 1) return ''; //don't return any header for page number 1
        return 'This is a header' || headerContent;
    "footerCallback" => "function(footerContent, pageNum, numPages){
        if (pageNum == numPages) return ''; //don't return any footer for the last page
        return 'This is a footer' || footerContent;


Lawrbit commented on May 25


We are doing the same as the code shared by you, When I am skipping the header and footer from the first page, the header, and footer white space (header footer height) remain the same.

Can help us set the header footer height to 0px for the first page and 100px for the other pages?

Sebastian Morales commented on May 26

I'm afraid that with Export package's Phantomjs pdf rendering engine, dynamic header/footer content across pages is possible but header/footer height is always fixed. The best solution for your case is to export the first page without header/footer and later pages with header/footer independently and then merge them:


//merge the pdf files here

There're multiple PHP packages to merge pdf files. For example:


$pdf = new \Jurosh\PDFMerge\PDFMerger;

// add as many pdfs as you want
$pdf->addPDF('path/to/source/file.pdf', 'all', 'vertical')
  ->addPDF('path/to/source/file1.pdf', 'all')
  ->addPDF('path/to/source/file2.pdf', 'all', 'horizontal');

// call merge, output format `file`
$pdf->merge('file', 'path/to/export/dir/file.pdf');

Or https://packagist.org/packages/karriere/pdf-merge

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