Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: PDF_add_weblink - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net

search for in the

PDF_arc" width="11" height="7"/> <PDF_add_thumbnail
Last updated: Wed, 01 Nov 2006
view this page in

PDF_add_weblink

(PHP 3 >= 3.0.12, PHP 4, PECL)

PDF_add_weblink -- 現在のページに Web リンクを追加する [古い関数]

説明

bool PDF_add_weblink ( resource pdfdoc, float lowerleftx, float lowerlefty, float upperrightx, float upperrighty, string url )

Web 上のターゲット url への Web リンクを追加します。 成功した場合に TRUE を、失敗した場合に FALSE を返します。

この関数は PDFlib バージョン 6 で廃止されました。かわりに type=URI とともに PDF_create_action()、 および type=Link とともに PDF_create_annotation() を使用してください。



add a note add a note User Contributed Notes
PDF_add_weblink
rz at daimi dot au dot dk
24-Mar-2005 07:07
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);
?>
js at justnet dot com dot au
06-Jun-2002 01:22
The example given in the above comment is potentially confusing, since the 4th and 5th arguments appear to be the width and height of the link area, but are actually the coordinates of the diagonally opposite corner. This is much more evident when the starting point for the weblink is something other than 0,0 (which is of course very likely).

A better example:

$starting_xpos = 100;
$starting_ypos = 150;
pdf_add_weblink($pdf, $starting_xpos, $starting_ypos, $starting_xpos + $width, $starting_ypos + $height, "http://goweb.com.au/");
bob at nijman dot de
02-Aug-2001 11:55
Try this:

<?php

//create & open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author","Bob Nijman");

//the interesting bit...
$pdfimage = pdf_open_image_file($pdf, "jpeg", "test.jpg");
$width = pdf_get_image_width($pdf, $pdfimage);
$height = pdf_get_image_height($pdf, $pdfimage);
pdf_begin_page($pdf, 421, 595);
pdf_place_image($pdf, $pdfimage, 0, 0, 1);
pdf_add_weblink($pdf, 0, 0, $width, $height, "http://www.hackeschermarkt.de");

//close it up
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_arc" width="11" height="7"/> <PDF_add_thumbnail
Last updated: Wed, 01 Nov 2006
 
 
show source | credits | sitemap | contact | advertising | mirror sites