/** * Constructor * * @param PMF_Faq $faq PMF_Faq object * @param PMF_Category $category PMF_Category object * * return PMF_Export_Pdf */ public function __construct(PMF_Faq $faq, PMF_Category $category) { $this->faq = $faq; $this->category = $category; $this->pdf = new PMF_Export_Pdf_Wrapper(); // Set PDF options $this->pdf->enableBookmarks = true; $this->pdf->isFullExport = true; $this->pdf->Open(); $this->pdf->AliasNbPages(); $this->pdf->SetDisplayMode('real'); }
/** * Builds the PDF delivery for the given faq. * * @param integer $currentCategory The category under which we want the PDF to be created. * @param string $pdfFile The path to the PDF file. Optional, default: pdf/<faq_id>.pdf. * @return mixed */ public function buildPDFFile($currentCategory, $pdfFile = null) { global $PMF_LANG; // Sanity check: stop here if getRecord() has not been called yet if (empty($this->faqRecord)) { return false; } // Default filename: pdf/<faq_id>.pdf if (empty($pdfFile)) { $pdfFile = 'pdf' . $this->faqRecord['id'] . '.pdf'; } $faqconfig = PMF_Configuration::getInstance(); $categoryNode = new PMF_Category_Node(); $categoryData = $categoryNode->fetch($currentCategory); $pdf = new PMF_Export_Pdf_Wrapper(); $pdf->faq = $this->faqRecord; $pdf->setCategory($categoryData); $pdf->setQuestion($this->faqRecord['title']); // Start building PDF... $pdf->Open(); // Set any item $pdf->SetTitle($this->faqRecord['title']); $pdf->SetCreator($faqconfig->get('main.titleFAQ') . ' - powered by phpMyFAQ ' . $faqconfig->get('main.currentVersion')); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('arialunicid0', '', 12); $pdf->SetDisplayMode('real'); $pdf->Ln(); $pdf->WriteHTML(str_replace('../', '', $this->faqRecord['content']), true); $pdf->Ln(); $pdf->Ln(); $pdf->SetFont('arialunicid0', '', 11); $pdf->Write(5, $PMF_LANG['ad_entry_solution_id'] . ': #' . $this->faqRecord['solution_id']); $pdf->SetAuthor($this->faqRecord['author']); $pdf->Ln(); $pdf->Write(5, $PMF_LANG['msgAuthor'] . ': ' . $this->faqRecord['author']); $pdf->Ln(); $pdf->Write(5, $PMF_LANG['msgLastUpdateArticle'] . $this->faqRecord['date']); // Build it return $pdf->Output($pdfFile); }