composer package updates
[openemr.git] / vendor / dompdf / dompdf / src / CanvasFactory.php
blobd9d22bed0d19a3bff0f2f588097d3b6dd60159cc
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;
10 /**
11 * Create canvas instances
13 * The canvas factory creates canvas instances based on the
14 * availability of rendering backends and config options.
16 * @package dompdf
18 class CanvasFactory
20 /**
21 * Constructor is private: this is a static class
23 private function __construct()
27 /**
28 * @param Dompdf $dompdf
29 * @param string|array $paper
30 * @param string $orientation
31 * @param string $class
33 * @return Canvas
35 static function get_instance(Dompdf $dompdf, $paper = null, $orientation = null, $class = null)
37 $backend = strtolower($dompdf->getOptions()->getPdfBackend());
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";
48 else {
49 if ($backend === "gd") {
50 $class = "Dompdf\\Adapter\\GD";
51 } else {
52 $class = "Dompdf\\Adapter\\CPDF";
57 return new $class($paper, $orientation, $dompdf);