function pdfAction() { $this->_helper->layout->setLayout('layout-misc-printpdf'); $this->_helper->viewRenderer->setNoRender(TRUE); $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : ''; define('K_TCPDF_EXTERNAL_CONFIG', true); define("K_PATH_MAIN", ROOT_DIR . "/library/PdfTool/tcpdf/"); define("K_PATH_URL", ROOT_URL . "/library/PdfTool/tcpdf/"); define("K_PATH_FONTS", K_PATH_MAIN . "fonts/"); define("K_PATH_CACHE", K_PATH_MAIN . "cache/"); define("K_PATH_URL_CACHE", K_PATH_URL . "cache/"); define("K_PATH_IMAGES", K_PATH_MAIN . "images/"); define("K_BLANK_IMAGE", K_PATH_IMAGES . "_blank.png"); define("PDF_PAGE_FORMAT", "A4"); define("PDF_PAGE_ORIENTATION", "P"); define("PDF_CREATOR", "HUKUMONLINE"); define("PDF_AUTHOR", "HUKUMONLINE"); define("PDF_HEADER_LOGO", "logo_hukumonline.jpg"); define("PDF_HEADER_LOGO_WIDTH", 30); define("PDF_UNIT", "mm"); define("PDF_MARGIN_HEADER", 5); define("PDF_MARGIN_FOOTER", 10); define("PDF_MARGIN_TOP", 27); define("PDF_MARGIN_BOTTOM", 25); define("PDF_MARGIN_LEFT", 15); define("PDF_MARGIN_RIGHT", 15); define("PDF_FONT_NAME_MAIN", "vera"); //vera define('PDF_FONT_MONOSPACED', 'courier'); define("PDF_FONT_SIZE_MAIN", 10); define("PDF_FONT_NAME_DATA", "vera"); //vera define("PDF_FONT_SIZE_DATA", 8); define("PDF_IMAGE_SCALE_RATIO", 4); define("HEAD_MAGNIFICATION", 1.1); define("K_CELL_HEIGHT_RATIO", 1.25); define("K_TITLE_MAGNIFICATION", 1.3); define("K_SMALL_RATIO", 2 / 3); $rowset = App_Model_Show_Catalog::show()->getCatalogByGuid($catalogGuid); $title = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedTitle'); $content = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedContent'); $description = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedDescription'); $author = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedAuthor'); $array_hari = array(1 => "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu"); $hari = $array_hari[date("N", strtotime($rowset['createdDate']))]; $date = $hari . ', ' . date("d F Y", strtotime($rowset['createdDate'])); require_once 'PdfTool/tcpdf/tcpdf.php'; // create new PDF document $pdf = new TCPDF(); define("PDF_HEADER_TITLE", "PT. Justika Siar Publika"); define("PDF_HEADER_STRING", "Puri Imperium Office Plaza, Jl. Kuningan Madya Kav 5-6 Kuningan Jakarta 12980,\nTelepon: (62-21) 83701827 / Faksimili: (62-21) 83701826\nE-mail: redaksi@hukumonline.com"); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings //$pdf->setLanguageArray($l); // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('dejavusans', '', 14, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); $registry = Zend_Registry::getInstance(); $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT); $cdn = $config->getOption('cdn'); $sDir = $cdn['static']['url']['images']; // $sDir = 'uploads/images'; $thumb = ""; $rowsetRelatedItem = App_Model_Show_RelatedItem::show()->getDocumentById($catalogGuid, 'RELATED_IMAGE'); $itemGuid = isset($rowsetRelatedItem['itemGuid']) ? $rowsetRelatedItem['itemGuid'] : ''; if (Pandamp_Lib_Formater::thumb_exists($sDir . "/" . $itemGuid . ".jpg")) { $thumb = $sDir . "/" . $itemGuid . ".jpg"; } if (Pandamp_Lib_Formater::thumb_exists($sDir . "/" . $itemGuid . ".gif")) { $thumb = $sDir . "/" . $itemGuid . ".gif"; } if (Pandamp_Lib_Formater::thumb_exists($sDir . "/" . $itemGuid . ".png")) { $thumb = $sDir . "/" . $itemGuid . ".png"; } if ($thumb == "") { $screenshot = ""; } else { $screenshot = "<img src=\"" . ROOT_URL . '/' . $thumb . "\" />"; } // Set some content to print $html = '<div class="kotakisi">'; $html .= '<h2>' . $title . '</h2>'; $html .= '<div class="tanggalterbit">' . $date . '</div>'; if ($description) { $html .= '<div class="description">' . $description . '</div>'; } if ($thumb == "") { $screenshot = ""; } else { $rowset = App_Model_Show_Catalog::show()->getCatalogByGuid($rowsetRelatedItem['itemGuid']); if (isset($rowset)) { $title = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset['guid'], 'fixedTitle'); } $html .= '<div class="image">' . $screenshot . '<br><span class="fname">' . $title . '</span></div>'; } $html .= '<p>' . Pandamp_Lib_Formater::_cleanMsWordHtml($content) . '</p>'; $html .= '</div>'; // Print text using writeHTMLCell() $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output('article.pdf', 'I'); }