Skip to content

Basic PDF support #80

@pxlrbt

Description

@pxlrbt

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);
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions