• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • PDF_add_weblink()

    (PHP 4, PECL pdflib >= 1.0.0)

    Add weblink for current page[deprecated]

    说明

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

    Adds a weblink annotation to a target$urlon the Web.成功时返回TRUE,或者在失败时返回FALSE

    This function is deprecated since PDFlib version 6, use PDF_create_action() withtype=URIand PDF_create_annotation() withtype=Linkinstead.

    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/");
    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_add_thumbnail()

    下篇:PDF_arc()