Example #1
0
 public function renderPdf($id, $platformId)
 {
     $article = new Article($id);
     if (!$article->exists()) {
         return $this->renderNotFound();
     }
     $markdown = new MarkdownParser();
     $pdf = new \mPDF();
     $pdf->WriteHTML(sprintf('<h1>%s</h1>', $article->title));
     if ($article->title) {
         $pdf->WriteHTML(sprintf('<h2>%s</h2>', $article->subTitle));
     }
     foreach ($article->getArticleSections() as $section) {
         foreach ($section->getBlocks($platformId) as $block) {
             $pdf->WriteHTML($markdown->transformMarkdown($block->content));
             $pdf->WriteHTML('<br/>');
         }
     }
     $pdf->Output();
     exit;
 }