Closed adhayward closed 3 years ago
I've done some digging into this issue and I believe the issue lies in how kartik\export\ExportWriterPdf
and it's parent class PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf
work.
Essentially the save function isn't overridden and sets a lot of the properties to values retrieved from the spreadsheet.
The settings defined in ExportMenu::pdfConfig
get passed to kartik\mpdf\Mpdf
but the output function in kartik\mpdf\Pdf never gets called so none of the properties set in the pdfConfig propagate down to the outputted pdf file.
I'm going to have a look at overriding the save function in ExportWriterPdf in such a way as to mimic the Pdf::output function which should hopefully allow all of the config to be passed correctly.
If I get it working I can post a Pull Request.
PR #344 gets the config to pass through however I encountered issues with the headers only appearing on page 1. I've put some code in to rectify that too but I feel like there should be a better way of fixing it.
div
with style='page: page0'
which was telling Mpdf to treat the whole table as one page, I've just done a str_replace to remove it but it may be that this needs rectifying in PhpSpreadsheet itself.tbody
rather than thead
and didn't repeat on each page, this can be rectified using $this->spreadsheet->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1,1);
. This assumes there is exactly 1 header row, if there is a way to identify the number of header rows then this could probably do with changing to use that.Thanks will check.
Any idea when this might be verified, and fixed if necessary?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Not sure if the issue lies in the yii2-export library or with the yii2-mpdf one but it seems that the pdfConfig doesn't get applied when exporting pdfs. I've checked the Control Export Formats demo and there the settings listed there don't apply to the PDF products (there is no header/footer and the various meta properties are not filled in.
Prerequisites
master
branch of yii2-export.Steps to reproduce the issue
Expected behavior and actual behavior
When I follow those steps, the PDF produced uses the default config, completely ignoring every option I've tried to specify.
I was expecting the config specified to affect the PDF produced
Environment
Browsers
Operating System
Libraries
Isolating the problem