ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
01simple-download-pdf.php
Go to the documentation of this file.
1<?php
29error_reporting(E_ALL);
30ini_set('display_errors', TRUE);
31ini_set('display_startup_errors', TRUE);
32date_default_timezone_set('Europe/London');
33
34if (PHP_SAPI == 'cli')
35 die('This example should only be run from a Web Browser');
36
38require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
39
40
41// Change these values to select the Rendering library that you wish to use
42// and its directory location on your server
43//$rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
45//$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
46//$rendererLibrary = 'tcPDF5.9';
47$rendererLibrary = 'mPDF5.4';
48//$rendererLibrary = 'domPDF0.6.0beta3';
49$rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererLibrary;
50
51
52// Create new PHPExcel object
54
55// Set document properties
56$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
57 ->setLastModifiedBy("Maarten Balliauw")
58 ->setTitle("PDF Test Document")
59 ->setSubject("PDF Test Document")
60 ->setDescription("Test document for PDF, generated using PHP classes.")
61 ->setKeywords("pdf php")
62 ->setCategory("Test result file");
63
64
65// Add some data
66$objPHPExcel->setActiveSheetIndex(0)
67 ->setCellValue('A1', 'Hello')
68 ->setCellValue('B2', 'world!')
69 ->setCellValue('C1', 'Hello')
70 ->setCellValue('D2', 'world!');
71
72// Miscellaneous glyphs, UTF-8
73$objPHPExcel->setActiveSheetIndex(0)
74 ->setCellValue('A4', 'Miscellaneous glyphs')
75 ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
76
77// Rename worksheet
78$objPHPExcel->getActiveSheet()->setTitle('Simple');
79$objPHPExcel->getActiveSheet()->setShowGridLines(false);
80
81// Set active sheet index to the first sheet, so Excel opens this as the first sheet
82$objPHPExcel->setActiveSheetIndex(0);
83
84
88 )) {
89 die(
90 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
91 '<br />' .
92 'at the top of this script as appropriate for your directory structure'
93 );
94}
95
96
97// Redirect output to a client’s web browser (PDF)
98header('Content-Type: application/pdf');
99header('Content-Disposition: attachment;filename="01simple.pdf"');
100header('Cache-Control: max-age=0');
101
103$objWriter->save('php://output');
$rendererName
Include PHPExcel.
$rendererLibraryPath
An exception for terminatinating execution or to throw for unit testing.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
const PDF_RENDERER_MPDF
Definition: Settings.php:51
static setPdfRenderer($libraryName, $libraryBaseDir)
Set details of the external library that PHPExcel should use for rendering PDF files.
Definition: Settings.php:287