enter image description here

I have an image I am trying to force to standard 8.5 x 11 for printing. Because of how it is rendered, I could figure out a way to get img src="" to work and all of the php functions I found blew out the memory when getting even close.

<?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);
?>
有帮助吗?

解决方案

If you want to resize your image on printing you can create a print.css. Include it in your html page with:

<link rel="stylesheet" href="print.css" screen="print">

..and then add your style property for the image that you want to be resized in print.css

img.yourimage
{
     width: newwidth;
     height: newheight;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top