Browsershot : show two pages per sheet

955 views Asked by At

I'm using the spatie/browsershot package with puppeteer to generate pdf in my applications. I have several templates for the generation, so I created a blade template for every template made.

I'm having a problem with one of the templates though, I'm trying to simulate two A5 pages printed on one A4 sheet (landscape mode). Doing this purely in css would be too difficult (calculate the end of the page, go on the other column at the right time, etc), so I generate it normally but with width and height set at the A5 dimensions. Of course, it appears right in the middle of the sheet, one page per sheet.

I wanted to know if there were a way to "glue" two pages together with Browsershot. Here's my call to generate the pdf:

$content = view('pdf.' . $survey->pdfTemplate->name, ['answer' => $answer)->render();

Browsershot::html($content)->noSandbox()->showBackground()->waitUntilNetworkIdle()->landscape($survey->pdfTemplate->is_landscape)->save(storage_path($id . '.pdf'));

I think that if there's a way to make such a thing, it must be here at the generation. Thanks a lot!

1

There are 1 answers

0
Sergey Karakhanyan On

I see your question is still open. I had the same problem because I had option ->format('A4') defined. I removed the option, and all pages still generating in A4 format as long as you use ->savePdf();