/** * @param WritableInterface $writable * @return void */ public function render(WritableInterface $writable) { $writable->accept($this->initializer); $documentName = $writable->getTitle() === true ? $writable->getTitle() : "document"; $content = $writable->accept($this->writer); $dompdf = new DOMPDF(); $dompdf->load_html($content); $dompdf->render(); $dompdf->stream($documentName . ".pdf"); }
/** * @param WritableInterface $writable * @return void */ public function render(WritableInterface $writable) { $writable->accept($this->initializer); $content = $writable->accept($this->writer); $filename = "title"; $filename = date("Y-m-d-") . "{$filename}.xlsx"; header("Content-Disposition: attachment; filename={$filename};"); header("Content-Type: application/octet-stream"); echo $content; }
/** * @param WritableInterface $writable * @return string */ protected function getContent(WritableInterface $writable) { foreach ($this->writers as $writer) { $content = $writable->accept($writer); if ($content !== null) { return $content; } } throw new \RuntimeException("No visit method for " . get_class($writable) . " found among writers"); }
/** * Visit a writable host and render it into html. * * @param WritableInterface $host * @return string */ protected function write(WritableInterface $host) { return $host->accept($this); }