_margin_header = $options['margin-header']; } if (isset($options['margin-footer'])) { $this->_margin_footer = $options['margin-footer']; } if (isset($options['margin-top'])) { $this->_margin_top = $options['margin-top']; } if (isset($options['margin-bottom'])) { $this->_margin_bottom = $options['margin-bottom']; } if (isset($options['margin-left'])) { $this->_margin_left = $options['margin-left']; } if (isset($options['margin-right'])) { $this->_margin_right = $options['margin-right']; } if (isset($options['image-scale'])) { $this->_image_scale = $options['image-scale']; } //set mime type $this->_mime = 'application/pdf'; //set document type $this->_type = 'pdf'; /* * Setup external configuration options */ // define('K_TCPDF_EXTERNAL_CONFIG', true); /* * Path options */ /* // Installation path define("K_PATH_MAIN", JPATH_VM_LIBRARIES.DS."tcpdf"); // URL path define("K_PATH_URL", JPATH_BASE); // Fonts path define("K_PATH_FONTS", K_PATH_MAIN.DS.'fonts'.DS); //define("K_PATH_FONTS", JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocapdf'.DS.'fonts'.DS) // Cache directory path define("K_PATH_CACHE", K_PATH_MAIN.DS."cache"); // Cache URL path define("K_PATH_URL_CACHE", K_PATH_URL.DS."cache"); // Images path define("K_PATH_IMAGES", K_PATH_MAIN.DS."images"); // Blank image path define("K_BLANK_IMAGE", K_PATH_IMAGES.DS."_blank.png"); /* * Format options */ /* // Cell height ratio define("K_CELL_HEIGHT_RATIO", 1.0); // Magnification scale for titles define("K_TITLE_MAGNIFICATION", 1.0); // Reduction scale for small font define("K_SMALL_RATIO", 1/3); // Magnication scale for head define("HEAD_MAGNIFICATION", 1.1); /* * Create the pdf document */ // Default settings are a portrait layout with an A4 configuration using millimeters as units if(!class_exists('TCPDF')) require(JPATH_ROOT.DS.'libraries'.DS.'tcpdf'.DS.'tcpdf.php'); $this->_engine = new TCPDF(); //set margins $this->_engine->SetMargins($this->_margin_left, $this->_margin_top, $this->_margin_right); //set auto page breaks $this->_engine->SetAutoPageBreak(TRUE, $this->_margin_bottom); $this->_engine->SetHeaderMargin($this->_margin_header); $this->_engine->SetFooterMargin($this->_margin_footer); $this->_engine->setImageScale($this->_image_scale); } /** * Sets the document name * * @param string $name Document name * @access public * @return void */ function setName($name = 'joomla') { $this->_name = $name; } /** * Returns the document name * * @access public * @return string */ function getName() { return $this->_name; } /** * Sets the document header string * * @param string $text Document header string * @access public * @return void */ function setHeader($text) { $this->_header = $text; } /** * Returns the document header string * * @access public * @return string */ function getHeader() { return $this->_header; } /** * Render the document. * * @access public * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * @return The rendered data */ function render( $cache = false, $params = array()) { $pdf = &$this->_engine; // Set PDF Metadata $pdf->SetCreator($this->getGenerator()); $pdf->SetTitle($this->getTitle()); $pdf->SetSubject($this->getDescription()); $pdf->SetKeywords($this->getMetaData('keywords')); // Set PDF Header data $pdf->setHeaderData('',0,$this->getTitle(), $this->getHeader()); // Set PDF Header and Footer fonts $lang = JFactory::getLanguage(); // $font = $lang->getPdfFontName(); // $font = ($font) ? $font : 'freesans'; $pdf->setRTL($lang->isRTL()); $pdf->SetFont('helvetica', '', 8, '', 'false'); $pdf->setHeaderFont(array($this->_header_font, '', 10)); $pdf->setFooterFont(array($this->_footer_font, '', 8)); // Initialize PDF Document $pdf->AliasNbPages(); $pdf->AddPage(); // Build the PDF Document string from the document buffer $this->fixLinks(); $pdf->WriteHTML($this->getBuffer(), true); $data = $pdf->Output('', 'S'); // Set document type headers parent::render(); //JResponse::setHeader('Content-Length', strlen($data), true); JResponse::setHeader('Content-type', 'application/pdf', true); JResponse::setHeader('Content-disposition', 'inline; filename="'.$this->getName().'.pdf"', true); //Close and output PDF document return $data; } function fixLinks() { } }