我有一张图像,我想强制打印到标准8.5 x 11。由于它的呈现方式,我想出了一种方法来使img src =“”工作,并且我发现所有php函数在接近时都会耗尽内存。
<?php
$image = imagecreatefrompng('/var/www/localhost/htdocs/contactdb/2.png');
header('Content-type: image/png');
$black = imagecolorallocate($image, 0, 0, 0);
$font_path = '/var/www/localhost/htdocs/contactdb/arial.ttf';
$text = "This is a message!";
imagettftext($image, 100, 0, 275, 800, $black, $font_path, $text);
imagepng($image);
imagedestroy($image);
?>
如果要在打印时调整图像大小,可以创建一个print.css。将其包含在您的html页面中,并包含以下内容:
<link rel="stylesheet" href="print.css" screen="print">
..,然后在print.css中为要调整大小的图像添加样式属性
img.yourimage
{
width: newwidth;
height: newheight;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句