/** * Test normal construct */ public function testConstruct() { define('DOMPDF_ENABLE_AUTOLOAD', false); $file = __DIR__ . "/../_files/temp.pdf"; $rendererName = Settings::PDF_RENDERER_DOMPDF; $rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf'); Settings::setPdfRenderer($rendererName, $rendererLibraryPath); $writer = new PDF(new PhpWord()); $writer->save($file); $this->assertTrue(file_exists($file)); unlink($file); }
/** * Test construct */ public function testConstruct() { $file = __DIR__ . '/../../_files/mpdf.pdf'; $phpWord = new PhpWord(); $section = $phpWord->addSection(); $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8')); $rendererName = Settings::PDF_RENDERER_MPDF; $rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/mpdf/mpdf'); Settings::setPdfRenderer($rendererName, $rendererLibraryPath); $writer = new PDF($phpWord); $writer->save($file); $this->assertTrue(file_exists($file)); unlink($file); }
/** * Test construct */ public function testConstruct() { $file = __DIR__ . "/../../_files/tcpdf.pdf"; $phpWord = new PhpWord(); $section = $phpWord->addSection(); $section->addText('Test 1'); $rendererName = Settings::PDF_RENDERER_TCPDF; $rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/tecnick.com/tcpdf'); Settings::setPdfRenderer($rendererName, $rendererLibraryPath); $writer = new PDF($phpWord); $writer->save($file); $this->assertTrue(file_exists($file)); unlink($file); }
/** * Test construct exception * * @expectedException \PhpOffice\PhpWord\Exception\Exception * @expectedExceptionMessage PDF rendering library or library path has not been defined. */ public function testConstructException() { $writer = new PDF(new PhpWord()); $writer->save(); }