Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Refactored the Dompdf class
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed Mar 23, 2014
1 parent ba752b6 commit cb247c2
Show file tree
Hide file tree
Showing 11 changed files with 661 additions and 362 deletions.
File renamed without changes.
2 changes: 0 additions & 2 deletions src/Dompdf/Adapter/CPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use Dompdf\Image\Cache;
use Dompdf\PhpEvaluator;

require_once(DOMPDF_LIB_DIR . "/class.pdf.php");

/**
* PDF rendering interface
*
Expand Down
2 changes: 0 additions & 2 deletions src/Dompdf/Adapter/TCPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Dompdf\Dompdf;
use Dompdf\Canvas;

require_once DOMPDF_LIB_DIR . '/tcpdf/tcpdf.php';

/**
* TCPDF PDF Rendering interface
*
Expand Down
5 changes: 5 additions & 0 deletions src/Dompdf/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static function register()
*/
public static function autoload($class)
{
if ($class === 'Cpdf') {
require_once __DIR__ . "/../../lib/Cpdf.php";
return;
}

$prefixLength = strlen(self::PREFIX);
if (0 === strncmp(self::PREFIX, $class, $prefixLength)) {
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
Expand Down
9 changes: 4 additions & 5 deletions src/Dompdf/CanvasFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class CanvasFactory
{

/**
* Constructor is private: this is a static class
*/
Expand All @@ -35,13 +34,13 @@ private function __construct()
*/
static function get_instance(Dompdf $dompdf, $paper = null, $orientation = null, $class = null)
{

$backend = strtolower(DOMPDF_PDF_BACKEND);
$DOMPDF_PDF_BACKEND = defined('DOMPDF_PDF_BACKEND') ? DOMPDF_PDF_BACKEND : 'CPDF';
$backend = strtolower($DOMPDF_PDF_BACKEND);

if (isset($class) && class_exists($class, false)) {
$class .= "_Adapter";
} else {
if ((DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib") &&
if (($DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib") &&
class_exists("PDFLib", false)
) {
$class = "Dompdf\\Adapter\\PDFLib";
Expand All @@ -66,4 +65,4 @@ class_exists("PDFLib", false)

return new $class($paper, $orientation, $dompdf);
}
}
}
Loading

0 comments on commit cb247c2

Please sign in to comment.