Generating Current View for PDF

Hi,

This is kinda part of filament from my point of view that's why i decided to ask here if anyone knows solution.

I am trying to develop action from filament, which will generate PDF from current view.

So action contains basic stuff

public function generatePdfAction(): Action
    {
        return Action::make('generatePdfAction')
            ->label('Generate PDF')
            ->extraAttributes(['data-generate-pdf' => true]) 
            ->action(function () {
                
            });
    }


And this is my livewire component with js to send current page HTML
<div>
    {{-- Care about people's approval and you will be their prisoner. --}}
    {!! $this->generatePdfAction()->render() !!}

    @push('scripts')
        <script>
            document.addEventListener('DOMContentLoaded', function () {
                document.querySelector('[data-generate-pdf]').addEventListener('click', function (e) {
                    e.preventDefault(); 

                    const fullHtml = document.documentElement.outerHTML;

                    Livewire.dispatch('generate-pdf', { html: fullHtml });
                });
            });
        </script>
    @endpush
</div>


And it works, PDF gets generated but issue arises that it is generated for tablet resolution and it is really narrow, any idea how can i get from filament html that is from my viewpoint? Is it possible or am I overeaching ?

Btw, I am using spaties laravel pdf package.
Was this page helpful?