I need to fill the existing excel sheet regularly and export it as pdf. But can’t do it so that the content fits the page.
$spreadsheet = IOFactory::load(Storage::path('Time&Attendance Template.xltx'));
$sheet = $spreadsheet->getActiveSheet();
$pdfWriter = new Tcpdf($spreadsheet);
$sheet->getCell('A1')->setValue(Str::random());
$pdfWriter->setPaperSize(PageSetup::PAPERSIZE_A4);
$pdfWriter->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
$pdfWriter->save($file = Storage::path('test.pdf'));
result:
same file in excel online without any scaling settings fits on one pdf page:
PS. I tried mpdf and dompdf generator. They get lines of fonts so wrong, not close enough with the original for me.