The result is pretty good except for the graphic (a bar) for which the bars don't have the good height (but I have pass the right values for the graphic).
The issue might be related to the fact that the chart is being rendered using JavaScript, which Browsershot might not be able to handle properly. One solution could be to use a headless browser like Puppeteer instead of Browsershot. Here's an example code snippet using Puppeteer:
use Spatie\Browsershot\Browsershot;
use Nesk\Puphpeteer\Puppeteer;
$puppeteer = new Puppeteer;
$browser = $puppeteer->launch();
$page = $browser->newPage();
$page->setContent($html);
$page->pdf(['path' => 'activities.pdf', 'landscape' => true]);
$browser->close();
This code uses Puppeteer to launch a headless browser, navigate to the HTML page, and generate a PDF with the chart properly rendered. Note that you'll need to install the nesk/puphpeteer package in addition to spatie/browsershot.
I'm answering myself, is the animation, this is why the bars do not have the correct height when taking the snapshot. Adding a
animation: false,
to the chartjs options, fixed my issue.
Cheers