I am using Mpdf to generate a pdf from a phpSpreadsheet object. It works pretty well, but if a numeric cell is followed by a string cell I get no gap between the cells. I suspect this is because the numeric cell is right-justified by default while the string is left-justified by default.
Example of poorly formatted output
If I generate an xlsx file there is no problem. Is there a way I can add padding so that the pdf output looks better?
<?php require_once __DIR__ . "/vendor/autoload.php"; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\IOFactory; $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet() ->getColumnDimension('A') ->setWidth(12); $spreadsheet->getActiveSheet() ->getColumnDimension('B') ->setWidth(12); $spreadsheet->getActiveSheet() ->getColumnDimension('C') ->setWidth(12); $spreadsheet->getActiveSheet() ->setCellValue("A1", 1234567) ->setCellValue("B1", 'ABCDEFG') ->setCellValue("C1", 'QWERTY'); header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="test.pdf"'); header('Cache-Control: max-age=0'); $objwriter = IOFactory::createwriter($spreadsheet,'Mpdf');; $objwriter->save("php://output");