note 51226 deleted from function.pdf-add-weblink by googleguy

From: Date: Tue, 22 Oct 2013 10:17:07 +0000
Subject: note 51226 deleted from function.pdf-add-weblink by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196974@lists.php.net to get a copy of this message
Note Submitter: rz at daimi dot au dot dk ---- Notice that the coordinates given are absolute - they aren't tranformed using the transformation matrix. The following example shows a simple function that shows an url and adds a weblink. As illustrated it only works when the page isn't transformed. <?php function linkxy($x,$y,$url,$font,$size) { global $pdf; pdf_setfont($pdf, $font, $size); pdf_show_xy($pdf,$url,$x,$y); pdf_add_weblink($pdf, $x-2, $y-2+pdf_get_value($pdf,"descender",$font)*$size, $x+2+pdf_stringwidth($pdf,$url,$font,$size), $y+2+pdf_get_value($pdf,"ascender",$font)*$size, $url); } $pdf = pdf_new(); pdf_open_file($pdf); pdf_begin_page($pdf, 595, 421); $font = PDF_findfont($pdf, "Helvetica", "host", 0); linkxy(50,300,"http://www.ruf.dk",$font,30); /* the following does not work, sorry */ pdf_translate($pdf,250,100); pdf_scale($pdf,0.6,1.2); linkxy(10,100,"http://www.google.com",$font,30); pdf_end_page($pdf); pdf_close($pdf); $data = pdf_get_buffer($pdf); header('Content-type: application/pdf'); header('Content-disposition: inline; filename=myTest.pdf'); header('Content-length: ' . strlen($data)); echo $data; pdf_delete($pdf); ?>

« previous php.notes (#196974) next »