略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: PDF_fit_image

2024-11-15

PDF_fit_image

(PECL pdflib >= 2.0.0)

PDF_fit_imagePlace image or template

说明

PDF_fit_image ( resource $pdfdoc , int $image , float $x , float $y , string $optlist ) : bool

Places an image or template on the page, subject to various options. 成功时返回 TRUE, 或者在失败时返回 FALSE

add a note add a note

User Contributed Notes 2 notes

up
-1
pcsmke et gmail dot com
8 years ago
<?php
$slika
= pdf_load_image($pdf,"gif","D:\\xampp\\htdocs\\telime.gif","");
pdf_fit_image($pdf,$slika,30,50,"");
pdf_close_image($pdf,$slika);
?>

this worked for me full path to the file
up
-1
adrian dot suter at epfl dot ch
12 years ago
Hello php cracks

First of all, the reference point of the image is its left, bottom corner. Furthermore, I just thought it would be nice to know some of the most used options that can be passed using the fifth parameter "string optlist".

Scaling the image (e.g. by a factor of 0.5)
<?php PDF_fit_image ( $pdf, $img, $x, $y, "scale 0.5" ) ?>

Rotating the image (e.g. by an angle of 45 degrees)
<?php PDF_fit_image ( $pdf, $img, $x, $y, "rotate 45" ) ?>
Note: The reference point rotates with the image!

Fitting the image into a virtual box
<?php PDF_fit_image ( $pdf, $img, $x, $y, "boxsize {200 100} fitmethod meet" ) ?>
Note: The box width and height (in Adobe points) would be given in the curly braces. Using the fitmethod "meet", the image would be ratio-scaled to be completely visible. Other methods are "clip" and "slice".

Multiple options can be used at the same time by simply concatenating them using a space. By the way, most pdf functions work exactly the same as the PDFlib functions. So just risk a look into the PFLlib documentations (use a search engine).

Hope this helped! Best regards - Adrian

官方地址:https://www.php.net/manual/en/function.pdf-fit-image.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3