Source for file PDF.php
Documentation is available at PDF.php
* Copyright (c) 2006 - 2009 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
/** PHPExcel root directory */
define('PHPEXCEL_ROOT', dirname(__FILE__ ) . '/../../');
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
/** PHPExcel_Writer_HTML */
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/HTML.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
/** PHPExcel_Shared_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
/** PHPExcel_HashTable */
require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
/** PHPExcel_Shared_PDF */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PDF.php';
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* Temporary storage directory
* Create a new PHPExcel_Writer_PDF
* @param PHPExcel $phpExcel PHPExcel object
* @param string $pFileName
public function save($pFilename = null) {
$fileHandle = fopen($pFilename, 'w');
if ($fileHandle === false) {
throw new Exception("Could not open file $pFilename for writing.");
//$html .= $this->generateHTMLHeader(false);
//$html .= $this->generateHTMLFooter();
// Default PDF paper size
$orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == 'landscape' ? 'L' : 'P';
$orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == 'landscape' ? 'L' : 'P';
$pdf = new TCPDF($orientation, 'pt', $paperSize);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetFont('freesans');
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
fwrite($fileHandle, $pdf->output($pFilename, 'S'));
* Get temporary storage directory
* Set temporary storage directory
* @param string $pValue Temporary storage directory
* @throws Exception Exception when directory does not exist
* @return PHPExcel_Writer_PDF
throw new Exception("Directory does not exist: $pValue");
|