コード例 #1
1
ファイル: SettingsTest.php プロジェクト: kaantunc/MYK-BOR
 /**
  * Test set/get PDF renderer
  */
 public function testSetGetPdfRenderer()
 {
     $domPdfPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf');
     $this->assertFalse(Settings::setPdfRenderer('FOO', 'dummy/path'));
     $this->assertTrue(Settings::setPdfRenderer(Settings::PDF_RENDERER_DOMPDF, $domPdfPath));
     $this->assertEquals(Settings::PDF_RENDERER_DOMPDF, Settings::getPdfRendererName());
     $this->assertEquals($domPdfPath, Settings::getPdfRendererPath());
     $this->assertFalse(Settings::setPdfRendererPath('dummy/path'));
 }
コード例 #2
0
ファイル: PDF.php プロジェクト: hcvcastro/pxp
 /**
  * Instantiate a new renderer of the configured type within this container class
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @throws \PhpOffice\PhpWord\Exception\Exception
  */
 public function __construct(PhpWord $phpWord)
 {
     $pdfLibraryName = Settings::getPdfRendererName();
     $pdfLibraryPath = Settings::getPdfRendererPath();
     if (is_null($pdfLibraryName) || is_null($pdfLibraryPath)) {
         throw new Exception("PDF rendering library or library path has not been defined.");
     }
     $includePath = str_replace('\\', '/', get_include_path());
     $rendererPath = str_replace('\\', '/', $pdfLibraryPath);
     if (strpos($rendererPath, $includePath) === false) {
         set_include_path(get_include_path() . PATH_SEPARATOR . $pdfLibraryPath);
     }
     $rendererName = get_class($this) . '\\' . $pdfLibraryName;
     $this->renderer = new $rendererName($phpWord);
 }