31 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/PDF/tcpdf.php';
166 $this->_font = $fontName;
186 $this->_paperSize = $pValue;
206 $this->_orientation = $pValue;
216 public function save($pFilename = null) {
218 $this->_phpExcel->garbageCollect();
224 $fileHandle = fopen($pFilename,
'w');
225 if ($fileHandle ===
false) {
226 throw new Exception(
"Could not open file $pFilename for writing.");
230 $this->_isPdf =
true;
242 $paperSize =
'LETTER';
247 $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
248 $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
251 $printPaperSize = $this->_phpExcel->getSheet($this->
getSheetIndex())->getPageSetup()->getPaperSize();
252 $printMargins = $this->_phpExcel->getSheet($this->
getSheetIndex())->getPageMargins();
256 if (!is_null($this->_orientation)) {
260 if (!is_null($this->_paperSize)) {
265 if (isset(self::$_paperSizes[$printPaperSize])) {
266 $paperSize = self::$_paperSizes[$printPaperSize];
271 $pdf =
new TCPDF($orientation,
'pt', $paperSize);
272 $pdf->setFontSubsetting(
false);
274 $pdf->SetMargins($printMargins->getLeft() * 72,$printMargins->getTop() * 72,$printMargins->getRight() * 72);
275 $pdf->SetAutoPageBreak(
true,$printMargins->getBottom() * 72);
279 $pdf->setPrintHeader(
false);
280 $pdf->setPrintFooter(
false);
285 $pdf->SetFont($this->_font);
286 $pdf->writeHTML($html);
289 $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
290 $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
291 $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
292 $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
293 $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
296 fwrite($fileHandle, $pdf->output($pFilename,
'S'));
321 if (is_dir($pValue)) {
322 $this->_tempDir = $pValue;
324 throw new Exception(
"Directory does not exist: $pValue");