/** * Add a link to the pdf * * @param string $url The url to link to * @param float $x The x position of the link * @param float $y The y position of the link * @param float $width The width of the link * @param float $height The height of the link */ function add_link($url, $x, $y, $width, $height) { $y = $this->y($y) - $height; if (strpos($url, '#') === 0) { // Local link $name = substr($url, 1); if ($name) { $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=" . substr($url, 1) . " linewidth=0"); } } else { list($proto, $host, $path, $file) = explode_url($url); if ($proto == "" || $proto == "file://") { return; } // Local links are not allowed $url = build_url($proto, $host, $path, $file); $url = str_replace("=", "%3D", rawurldecode($url)); $action = $this->_pdf->create_action("URI", "url=" . $url); $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate={$action}} linewidth=0"); } }