PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Classes/PHPExcel/Writer/PDF.php

https://github.com/iGroup/PHPExcel
PHP | 85 lines | 30 code | 10 blank | 45 comment | 4 complexity | 16b0d7e584e427b332f9f5cde9f5dd7a MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2012 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 - 2012 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. * PHPExcel_Writer_PDF
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Writer_PDF
  32. * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Writer_PDF
  35. {
  36. private $_renderer = NULL;
  37. /**
  38. * Instantiate a new renderer of the configured type within this container class
  39. *
  40. * @param PHPExcel $phpExcel PHPExcel object
  41. * @throws PHPExcel_Writer_Exception Exception when PDF library is not configured
  42. */
  43. public function __construct(PHPExcel $phpExcel)
  44. {
  45. $pdfLibraryName = PHPExcel_Settings::getPdfRendererName();
  46. if (is_null($pdfLibraryName)) {
  47. throw new PHPExcel_Writer_Exception("PDF Rendering library has not been defined.");
  48. }
  49. $pdfLibraryPath = PHPExcel_Settings::getPdfRendererPath();
  50. if (is_null($pdfLibraryName)) {
  51. throw new PHPExcel_Writer_Exception("PDF Rendering library path has not been defined.");
  52. }
  53. $includePath = str_replace('\\', '/', get_include_path());
  54. $rendererPath = str_replace('\\', '/', $pdfLibraryPath);
  55. if (strpos($rendererPath, $includePath) === false) {
  56. set_include_path(get_include_path() . PATH_SEPARATOR . $pdfLibraryPath);
  57. }
  58. $rendererName = 'PHPExcel_Writer_PDF_' . $pdfLibraryName;
  59. $this->_renderer = new $rendererName($phpExcel);
  60. }
  61. /**
  62. * Magic method to handle direct calls to the configured PDF renderer wrapper class
  63. *
  64. * @param string $name Renderer library method name
  65. * @param mixed[] $arguments Array of arguments to pass to the renderer method
  66. * @return mixed Returned data from the PDF renderer wrapper method
  67. */
  68. public function __call($name, $arguments)
  69. {
  70. if ($this->_renderer === NULL) {
  71. throw new PHPExcel_Writer_Exception("PDF Renderer has not been defined.");
  72. }
  73. return call_user_func_array(array($this->_renderer, $name), $arguments);
  74. }
  75. }