I've successfully convert Excel to PDF using this code:
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Tcpdf');
$writer->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
header("Content-Disposition: attachment; filename=test.pdf");
$writer->save('php://output');
My problem is, the Excels has too many columns so the generated PDF crop the data.
Is it possible to either:
- Fit the Excel into A4 Landscape (make the Excel scale smaller)
- Auto resize the PDF to fit the content (it will be bigger than A4 and not necessary standard US Paper Size)