canvas_factory.cls.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * DOMPDF - PHP5 HTML to PDF renderer
  4. *
  5. * File: $RCSfile: canvas_factory.cls.php,v $
  6. * Created on: 2004-06-02
  7. *
  8. * Copyright (c) 2004 - Benj Carson <benjcarson@digitaljunkies.ca>
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public License
  21. * along with this library in the file LICENSE.LGPL; if not, write to the
  22. * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  23. * 02111-1307 USA
  24. *
  25. * Alternatively, you may distribute this software under the terms of the
  26. * PHP License, version 3.0 or later. A copy of this license should have
  27. * been distributed with this file in the file LICENSE.PHP . If this is not
  28. * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
  29. *
  30. * The latest version of DOMPDF might be available at:
  31. * http://www.dompdf.com/
  32. *
  33. * @link http://www.dompdf.com/
  34. * @copyright 2004 Benj Carson
  35. * @author Benj Carson <benjcarson@digitaljunkies.ca>
  36. * @package dompdf
  37. */
  38. /* $Id: canvas_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
  39. /**
  40. * Create canvas instances
  41. *
  42. * The canvas factory creates canvas instances based on the
  43. * availability of rendering backends and config options.
  44. *
  45. * @package dompdf
  46. */
  47. class Canvas_Factory {
  48. /**
  49. * Constructor is private: this is a static class
  50. */
  51. private function __construct() { }
  52. static function get_instance($paper = null, $orientation = null, $class = null) {
  53. $backend = strtolower(DOMPDF_PDF_BACKEND);
  54. if ( isset($class) && class_exists($class, false) )
  55. $class .= "_Adapter";
  56. else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
  57. class_exists("PDFLib", false) )
  58. $class = "PDFLib_Adapter";
  59. else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") )
  60. $class = "CPDF_Adapter";
  61. else if ( ( $backend === "tcpdf") )
  62. $class = "TCPDF_Adapter";
  63. else if ( $backend === "gd" )
  64. $class = "GD_Adapter";
  65. else
  66. $class = "CPDF_Adapter";
  67. return new $class($paper, $orientation);
  68. }
  69. }