KoolReport's Forum

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

Skip Header and Footer for First Page of PDF #1833

Open Mukesh opened this topic on on Jan 9, 2021 - 1 comments

Mukesh commented on Jan 9, 2021

Hello,

I am trying to skip the header and footer for the first page of the report it's working but how to do it with HTML or in view. If I am trying to pass HTML into return then it's not working.

Below is my code:

$headerContent = '<div class="page-header" style="height:80px; margin-right: 0px; padding: 0px;">
		<div style="color:#333333; width:100%; font-size:12px; border-bottom:1px solid #666666; padding-bottom:5px; height: 50px;">
			<div style="float: left; text-align:left; width:70%; padding-top:2px; padding-bottom:10px; height:40px;">
				<strong style="font-size:16px; color:#000000;">Title</strong><br>
				<span style="font-size:11px; color:#333333; font-style: italic;">Report Date </span>
			</div>
			<div style="float: right; width:30%; padding-top:8px;">
				<a style="float:right;"><img src="'.$imgURL.'" style="float:right; min-width:40px; max-width:100px; max-height:50px; margin-right: 2px;"></a>
			</div>
		</div>
	</div>';

$report->export('Template_View')
			->pdf(array(
					"width"=>"1024px",
					"height"=>"768px",
					"headerCallback" => "function(headerContent, pageNum, numPages){
						if (pageNum == 1) return '';
						return '$headerContent' || headerContent;
					}",
					"footerCallback" => "function(footerContent, pageNum, numPages){
						if (pageNum == numPages) return ''; //don't return any footer for the last page
						return footerContent;
					}"
				)
			)->saveAs($pdfPath);

Please explain how can we do it and how can we do it using view only.

Sebastian Morales commented on Jan 11, 2021

At the moment we only have api to call headerCallback and footerCallback in the export command. Yours is a nice suggestion. We will see if there's a possible way to set the callback functions in the view itself. Cheers,

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
None yet

None