PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpexcel / Classes / PHPExcel / Writer / PDF / DomPDF.php

DomPDF.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.0.3, at vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/PDF/DomPDF.php

123 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHPExcel
4 *
5 * Copyright (c) 2006 - 2014 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_Writer_PDF
23 * @copyright Copyright (c) 2006 - 2014 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
29 /** Require DomPDF library */
30 $pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
31 if (file_exists($pdfRendererClassFile)) {
32 require_once $pdfRendererClassFile;
33 } else {
34 throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
35 }
36
37 /**
38 * PHPExcel_Writer_PDF_DomPDF
39 *
40 * @category PHPExcel
41 * @package PHPExcel_Writer_PDF
42 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
43 */
44 class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
45 {
46 /**
47 * Create a new PHPExcel_Writer_PDF
48 *
49 * @param PHPExcel $phpExcel PHPExcel object
50 */
51 public function __construct(PHPExcel $phpExcel)
52 {
53 parent::__construct($phpExcel);
54 }
55
56 /**
57 * Save PHPExcel to file
58 *
59 * @param string $pFilename Name of the file to save as
60 * @throws PHPExcel_Writer_Exception
61 */
62 public function save($pFilename = NULL)
63 {
64 $fileHandle = parent::prepareForSave($pFilename);
65
66 // Default PDF paper size
67 $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
68
69 // Check for paper size and page orientation
70 if (is_null($this->getSheetIndex())) {
71 $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
72 == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
73 ? 'L'
74 : 'P';
75 $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
76 $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
77 } else {
78 $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
79 == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
80 ? 'L'
81 : 'P';
82 $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
83 $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
84 }
85
86
87 $orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
88
89 // Override Page Orientation
90 if (!is_null($this->getOrientation())) {
91 $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
92 ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT
93 : $this->getOrientation();
94 }
95 // Override Paper Size
96 if (!is_null($this->getPaperSize())) {
97 $printPaperSize = $this->getPaperSize();
98 }
99
100 if (isset(self::$_paperSizes[$printPaperSize])) {
101 $paperSize = self::$_paperSizes[$printPaperSize];
102 }
103
104
105 // Create PDF
106 $pdf = new DOMPDF();
107 $pdf->set_paper(strtolower($paperSize), $orientation);
108
109 $pdf->load_html(
110 $this->generateHTMLHeader(FALSE) .
111 $this->generateSheetData() .
112 $this->generateHTMLFooter()
113 );
114 $pdf->render();
115
116 // Write to file
117 fwrite($fileHandle, $pdf->output());
118
119 parent::restoreStateAfterSave($fileHandle);
120 }
121
122 }
123