G
G
Galdar Turin2019-03-13 10:49:27
phpspreadsheet
Galdar Turin, 2019-03-13 10:49:27

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');

does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Galdar Turin, 2019-03-13
@Galdar

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 question

Ask a Question

731 491 924 answers to any question