note 51226 added to function.pdf-add-weblink

From: Date: Wed, 23 Mar 2005 22:07:41 +0000
Subject: note 51226 added to function.pdf-add-weblink
Groups: php.notes 
Request: Send a blank email to php-notes+get-86864@lists.php.net to get a copy of this message
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); ?> ---- Manual Page -- http://www.php.net/manual/en/function.pdf-add-weblink.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51226 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51226&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51226&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51226&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51226&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51226&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51226&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86864) next »