commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / vendor / dompdf / dompdf / src / CanvasFactory.php
1 <?php
2 /**
3 * @package dompdf
4 * @link http://dompdf.github.com/
5 * @author Benj Carson <benjcarson@digitaljunkies.ca>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8 namespace Dompdf;
9
10 /**
11 * Create canvas instances
12 *
13 * The canvas factory creates canvas instances based on the
14 * availability of rendering backends and config options.
15 *
16 * @package dompdf
17 */
18 class CanvasFactory
19 {
20 /**
21 * Constructor is private: this is a static class
22 */
23 private function __construct()
24 {
25 }
26
27 /**
28 * @param Dompdf $dompdf
29 * @param string|array $paper
30 * @param string $orientation
31 * @param string $class
32 *
33 * @return Canvas
34 */
35 static function get_instance(Dompdf $dompdf, $paper = null, $orientation = null, $class = null)
36 {
37 $backend = strtolower($dompdf->get_option('pdf_backend'));
38
39 if (isset($class) && class_exists($class, false)) {
40 $class .= "_Adapter";
41 } else {
42 if (($backend === "auto" || $backend === "pdflib") &&
43 class_exists("PDFLib", false)
44 ) {
45 $class = "Dompdf\\Adapter\\PDFLib";
46 }
47
48 else {
49 if ($backend === "gd") {
50 $class = "Dompdf\\Adapter\\GD";
51 } else {
52 $class = "Dompdf\\Adapter\\CPDF";
53 }
54 }
55 }
56
57 return new $class($paper, $orientation, $dompdf);
58 }
59 }