"Fossies" - the Fresh Open Source Software Archive

Member "ILIAS-5.4.9/libs/composer/vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple_download_pdf.php" (24 Jan 2020, 1758 Bytes) of package /linux/www/ILIAS-5.4.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "01_Simple_download_pdf.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 use PhpOffice\PhpSpreadsheet\Helper\Sample;
    4 use PhpOffice\PhpSpreadsheet\IOFactory;
    5 use PhpOffice\PhpSpreadsheet\Spreadsheet;
    6 
    7 require_once __DIR__ . '/../../src/Bootstrap.php';
    8 
    9 $helper = new Sample();
   10 if ($helper->isCli()) {
   11     $helper->log('This example should only be run from a Web Browser' . PHP_EOL);
   12 
   13     return;
   14 }
   15 
   16 // Create new Spreadsheet object
   17 $spreadsheet = new Spreadsheet();
   18 
   19 // Set document properties
   20 $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
   21     ->setLastModifiedBy('Maarten Balliauw')
   22     ->setTitle('PDF Test Document')
   23     ->setSubject('PDF Test Document')
   24     ->setDescription('Test document for PDF, generated using PHP classes.')
   25     ->setKeywords('pdf php')
   26     ->setCategory('Test result file');
   27 
   28 // Add some data
   29 $spreadsheet->setActiveSheetIndex(0)
   30     ->setCellValue('A1', 'Hello')
   31     ->setCellValue('B2', 'world!')
   32     ->setCellValue('C1', 'Hello')
   33     ->setCellValue('D2', 'world!');
   34 
   35 // Miscellaneous glyphs, UTF-8
   36 $spreadsheet->setActiveSheetIndex(0)
   37     ->setCellValue('A4', 'Miscellaneous glyphs')
   38     ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
   39 
   40 // Rename worksheet
   41 $spreadsheet->getActiveSheet()->setTitle('Simple');
   42 $spreadsheet->getActiveSheet()->setShowGridLines(false);
   43 
   44 // Set active sheet index to the first sheet, so Excel opens this as the first sheet
   45 $spreadsheet->setActiveSheetIndex(0);
   46 
   47 IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class);
   48 
   49 // Redirect output to a client’s web browser (PDF)
   50 header('Content-Type: application/pdf');
   51 header('Content-Disposition: attachment;filename="01simple.pdf"');
   52 header('Cache-Control: max-age=0');
   53 
   54 $writer = IOFactory::createWriter($spreadsheet, 'Pdf');
   55 $writer->save('php://output');
   56 exit;