-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PdfWriter Mpdf orientation bug #1691
Comments
PhpSpreadsheet allows the setting of different page size and orientation on each sheet. So, instead of setting the orientation on the PDF writer, you could instead do something like the following before doing your write: foreach ($spreadsheetPDF->getAllSheets() as $worksheet) {
$worksheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
} I agree that this is not quite so convenient as your existing code, but it should produce the result you want. I will look into what is needed to make the writer override the orientation for a sheet only when the sheet hasn't explicitly specified a non-default orientation. The same should probably happen for paper size, which is slightly more difficult. |
Fix PHPOffice#1691. PhpSpreadsheet allows the setting of different page size and orientation on each worksheet. It also allows the setting of page size and orientation on the PDF writer. It isn't clear which is supposed to prevail when the two are in conflict. In the cited issue, the user expects the PDF writer setting to prevail, and I tend to agree. Code is changed to do this, and handling things in this manner is now explicitly documented. PhpSpreadsheet uses a default paper size of Letter, and a default orientation of Default (which Excel treats as Portrait). New static routines are added to change the default for sheets created subsequent to such calls. This could allow users to configure these defaults better for their environments. The new functions are added to the documentation.
Fix #1691. PhpSpreadsheet allows the setting of different page size and orientation on each worksheet. It also allows the setting of page size and orientation on the PDF writer. It isn't clear which is supposed to prevail when the two are in conflict. In the cited issue, the user expects the PDF writer setting to prevail, and I tend to agree. Code is changed to do this, and handling things in this manner is now explicitly documented. PhpSpreadsheet uses a default paper size of Letter, and a default orientation of Default (which Excel treats as Portrait). New static routines are added to change the default for sheets created subsequent to such calls. This could allow users to configure these defaults better for their environments. The new functions are added to the documentation.
I have already found the solution i think, but i'm not practical with pull request. I'm not used to it :( sorry
This is:
What is the expected behavior?
The orientation to be what i've set when i created the pdf writer
What is the current behavior?
The orientation get overwritten mistakenly by the code
What are the steps to reproduce?
Quite easy,
The fix should also be easy i guess. File is: src/PhpSpreadsheet/Writer/Pdf/Mpdf.php
This is an extract of the save function:
Which versions of PhpSpreadsheet and PHP are affected?
composer.json:
"phpoffice/phpspreadsheet": "^1.10",
PHP version: 7.3.21
The text was updated successfully, but these errors were encountered: