Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi,
Unfortunately at the moment headless Chrome hasn't support such customization of of header/footer for a certain page. There's some trick to set margin=0 for some pages to hide their header/footer but it's not consistent. While we wait for headless Chrome to support customized header/footer, I think the best solution for your case is to print different pdf files using "pageRange" option like this:
//Export.php
$report->cloudExport("MyReportPdf")
->chromeHeadlessio($secretToken)
->settings($settings)
->pdf([
...//set options here to disable header/footer
"pageRanges" => '1', //print only the first page
])
->saveAs($pathToExportFilePdf1);
;
$report->cloudExport("MyReportPdf")
->chromeHeadlessio($secretToken)
->settings($settings)
->pdf([
...//set options here to enable header/footer
"pageRanges" => '2-', //print page 2 -> end
])
->saveAs($pathToExportFilePdf2);
;
//Merge $pathToExportFilePdf1 and $pathToExportFilePdf2 here and return it to client
Let us know if you have any difficulty with each step. Thanks!
it's not working giving error Filename cannot be empty .
So I am doing like this, code is below:
$chromePDFOptions = array("scale"=>1, "format"=>"A4", "landscape"=>true);
$services = new \chromeheadlessio\Service("Token");
$report = new MyReport;
$services->export([
"html"=>$html
])->pdf([
//"format"=>"A4",
"displayHeaderFooter"=>false,
"printBackground"=>false,
"orientation"=>"portrait",
"width"=>"900px",
"height"=>"1070px",
"pageRanges" => "2-",
])->save('..pdf/certificateReport.pdf');
this is generating pdf but only a single PDF.
If I am redeclaring this its giving error you can't redeclare.
I am using cloud export if I purchase an export library then can I achieve this without creating 2 different pdf, I want this functionality in a single PDF
Good news! I have confirmation from the development team that the next version of Export package will allow user's different customization of header and footer for each page. If you have purchased either the Export package or KoolReport Pro please send us an email to support@koolphp.net. We will send you the development version of Export which could solve this issue. Thanks!
For those who are interested, I found a simple workaround.
Add this to your css:
@page:first {margin-top: 0;margin-bottom: 0;} body {margin-top: 1,25cm;margin-bottom: 1,25cm;}
And add this to the beginning of your view:
<div id="hide-frontpage-header" style="height: 50px ; width: 100%; background-color: white;"></div>
<div id="hide-frontpage-footer" style="position:absolute; bottom: 0; height: 50px; width: 100%; background-color: white;"></div>
The header and footer are covered by the white divs.
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo