mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-24 19:18:18 +00:00
e742bf2294
* Attempt To Honor Fit to 1-Page Height for Html/Pdf Fix #3266. Each sheet in a spreadsheet can specify that it be set to fit width or height to a fixed number of pages. Mpdf and most browsers already handle the common case of fit to 1 page wide; I am unable to find a solution for Dompdf or Tcpdf. Code is added for the common case of fit to 1 page high when possible; this will usually work in Mpdf, Dompdf, and most browsers. I am not able to come up with a way to handle fit to more than 1 page wide or high. * Synchronizer Remove one unused assignment in test.
22 lines
633 B
PHP
22 lines
633 B
PHP
<?php
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
|
|
|
|
require __DIR__ . '/../Header.php';
|
|
|
|
// Issue 3266 - spreadsheet specified fitToHeight.
|
|
$helper->log('Read spreadsheet');
|
|
$filename = '21d_FitToHeightPdf.xlsx';
|
|
$fileWithPath = __DIR__ . "/../templates/$filename";
|
|
$reader = new Xlsx();
|
|
$spreadsheet = $reader->load($fileWithPath);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
|
$helper->log('Write to Mpdf');
|
|
$writer = new Mpdf($spreadsheet);
|
|
$filename = $helper->getfilename($filename, 'pdf');
|
|
$writer->save($filename);
|
|
$helper->log("Saved $filename");
|
|
$spreadsheet->disconnectWorksheets();
|