spreadsheet->getSheet($this->getSheetIndex() ?? 0)->getPageSetup(); $orientation = $this->getOrientation() ?? $setup->getOrientation(); $orientation = ($orientation === PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->getPaperSize() ?? $setup->getPaperSize(); $paperSize = self::$paperSizes[$printPaperSize] ?? PageSetup::getPaperSizeDefault(); $orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; // Create PDF $pdf = $this->createExternalWriterInstance(); $pdf->setPaper($paperSize, $orientation); $pdf->loadHtml($this->generateHTMLAll()); $pdf->render(); // Write to file fwrite($fileHandle, $pdf->output() ?? ''); parent::restoreStateAfterSave(); } }