verumconsilium / laravel-browsershot

Browsershot wrapper for Laravel 5
MIT License
110 stars 19 forks source link

anyone get ApexCharts to render in PDF? i get blank #25

Open cjaoude opened 3 years ago

cjaoude commented 3 years ago

Anyone get ApexCharts to render in PDF? In a regular view, the chart renders fine, but in a PDF I get blank.

Thanks.


Separately, narrowed down an issue that had me going at first.

Blade template tags in the view seem to cause issues. Using for example {{ asset('js/app.js') }} causes an error. Even though it's a bare bones view.

Error: TimeoutError: Navigation timeout of 30000 ms exceeded

akhan619 commented 3 years ago

Can confirm. Issue is still present. Even a simple css {{ asset('css/app.css') }} will lead to timeout.

akhan619 commented 3 years ago

Ok. Played around with things a bit and had the same issue of timeout of 30000 ms when try to convert a view on Localhost. I was running it via php artisan serve. After playing around on a new Laravel project I narrowed it down to the use of a specific blade command.

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

The issue seems to be that puppeteer is not handling local network requests. For now I have gotten it to work as follows:

@env('local')
      @php
            echo '<style>' . file_get_contents(realpath(public_path('css/app.css'))) . '</style>';
      @endphp
@endenv
@env(['staging', 'production'])
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
@endenv

The above works without a hitch. So something is up with localhost uri resources in puppeteer.