"Fossies" - the Fresh Open Source Software Archive 
Member "groupoffice-6.4.213-php-71/vendor/phpoffice/phpexcel/Examples/01simple-download-pdf.php" (22 Nov 2018, 3567 Bytes) of package /linux/www/groupoffice-6.4.213-php-71.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.
1 <?php
2 /**
3 * PHPExcel
4 *
5 * Copyright (c) 2006 - 2015 PHPExcel
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 * @category PHPExcel
22 * @package PHPExcel
23 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
26 */
27
28 /** Error reporting */
29 error_reporting(E_ALL);
30 ini_set('display_errors', TRUE);
31 ini_set('display_startup_errors', TRUE);
32 date_default_timezone_set('Europe/London');
33
34 if (PHP_SAPI == 'cli')
35 die('This example should only be run from a Web Browser');
36
37 /** Include PHPExcel */
38 require_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;
44 $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
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
53 $objPHPExcel = new PHPExcel();
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
85 if (!PHPExcel_Settings::setPdfRenderer(
86 $rendererName,
87 $rendererLibraryPath
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)
98 header('Content-Type: application/pdf');
99 header('Content-Disposition: attachment;filename="01simple.pdf"');
100 header('Cache-Control: max-age=0');
101
102 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
103 $objWriter->save('php://output');
104 exit;