Answer the question
In order to leave comments, you need to log in
How to prescribe a specific sheet format for pdf?
It is necessary that the pdf sheet be saved in the PAPERSIZE_C5_ENVELOPE format, I write like this:
require 'vendor/autoload.php';
require 'configScript.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writerPDF = new Mpdf($spreadsheet);
$writerPDF->getPaperSize()->setPaperSize(PhpOffice\PhpSpreadsheet\Writer\Pdf::PAPERSIZE_C5_ENVELOPE);
$writerPDF->writeAllSheets()
->setPreCalculateFormulas(false)
->save('envelope.pdf');
Answer the question
In order to leave comments, you need to log in
Decision
$sheet->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C5_ENVELOPE);
$sheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question