Skip to content
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

Basic PDF support #80

Open
pxlrbt opened this issue May 30, 2023 · 0 comments
Open

Basic PDF support #80

pxlrbt opened this issue May 30, 2023 · 0 comments

Comments

@pxlrbt
Copy link
Owner

pxlrbt commented May 30, 2023

From Discord:

Hi Dennis, I hope you're doing well. I just wanted to let you know that I was able to landscape the PDF using the event as you suggested. Thank you for your help!
Here are the code I have used:

Sheet::listen(BeforeSheet::class, function ($sheet) {
            $sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);

            $sheet->getDelegate()->getStyle('1')->getFont()->setSize(8);
        });

However, you can use the RegistersEventListeners trait to automatically register the event listeners. To do so, simply add the trait to your class and include this function within your class:
beforeSheet(BeforeSheet $event)
{
$event->sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
}

or you can just add this one in your Page without trait

public function boot()
    {
        Sheet::listen(BeforeSheet::class, function ($sheet) {
            $sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);

            $sheet->getDelegate()->getStyle('1')->getFont()->setSize(8);
        });
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant