- Offizieller Beitrag
Dieses Paket hat für Endanwender keinen Nutzen!
WCF 2.0/2.1
Siehe GitHub - dompdf/dompdf: HTML to PDF converter (PHP5)
Codebeispiel
PHP
Alles anzeigen
- // load dompdf library
- require_once(WCF_DIR.'/lib/system/api/dompdf/autoload.php');
- $pdf = new Dompdf();
- $pdf->getOptions()->setTempDir(WCF_DIR.'tmp/');
- $pdf->getOptions()->setLogOutputFile(WCF_DIR.'tmp/dompdf.log');
- $pdf->getOptions()->setIsRemoteEnabled(true);
- $pdf->loadHtml(TemplateEngine::getInstance()->fetch('template', 'wcf', array(
- 'template' => 'template'
- )));
- $pdf->render();
- $tempFile = FileUtil::getTemporaryFilename();
- file_put_contents($tempFile, $pdf->output());
- $fileReader = new FileReader($tempFile, array(
- 'filename' => "file.pdf",
- 'mimeType' => 'application/pdf',
- 'filesize' => filesize($tempFile),
- 'showInline' => true,
- 'enableRangeSupport' => false,
- 'expirationDate' => TIME_NOW,
- 'maxAge' => 0
- ));
- // send file to client
- $fileReader->send();
- @unlink($tempFile);