function reset(&$media) { OutputDriverGenericPDF::reset($media); // Check if PDFLIB is available if (!extension_loaded('pdf')) { // Try to use "dl" to dynamically load PDFLIB $result = dl(PDFLIB_DL_PATH); if (!$result) { readfile(HTML2PS_DIR . 'templates/missing_pdflib.html'); error_log("No PDFLIB extension found"); die("HTML2PS Error"); } } $this->pdf = pdf_new(); // Set PDF compatibility level pdf_set_parameter($this->pdf, "compatibility", $this->get_pdf_version()); /** * Use PDF license key, if present * * PDFLIB_LICENSE constant is defined in 'config.inc.php' file in "PDFLIB-specific" section. */ if (defined("PDFLIB_LICENSE")) { pdf_set_parameter($this->pdf, "license", PDFLIB_LICENSE); } pdf_open_file($this->pdf, $this->get_filename()); // @TODO: compression level, debug pdf_set_value($this->pdf, "compress", 0); // Set path to the PDFLIB UPR file containig information about fonts and encodings if (defined("PDFLIB_UPR_PATH")) { pdf_set_parameter($this->pdf, "resourcefile", PDFLIB_UPR_PATH); } // Setup encodings not bundled with PDFLIB $filename = $this->generate_cpg('koi8-r'); pdf_set_parameter($this->pdf, 'Encoding', sprintf('koi8-r=%s', $filename)); // Setup font outlines global $g_font_resolver_pdf; $g_font_resolver_pdf->setup_ttf_mappings($this->pdf); $pdf = $this->pdf; pdf_set_info($pdf, "Creator", "html2ps (PHP version)"); // No borders around links in the generated PDF pdf_set_border_style($this->pdf, "solid", 0); $this->_status = PDFLIB_STATUS_DOCUMENT_STARTED; }
function add_link($url, $caption) { $oh = pdf_get_value($this->pdf, 'texty', 0); pdf_show($this->pdf, $caption); $y = pdf_get_value($this->pdf, 'texty', 0); $w = pdf_get_value($this->pdf, 'textx', 0); $ow = pdf_get_value($this->pdf, 'textx', 0) - pdf_stringwidth($this->pdf, $caption); pdf_set_border_style($this->pdf, 'dashed', 0); pdf_add_weblink($this->pdf, $ow, $oh, $w, $oh + 12, $url); }