This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Image Size

spyke01 wrote on 2010-10-18:
What is the best way to force an image to be the correct size, it seems when I have an image it gets enlarged, I tried the width and height attributes on the img tag and also within the style attributes but neither seem to work.
support wrote on 2010-10-18:
Set the width and height attributes on the img tag to 75% of the image dimensions.

Please, find the explanation in this thread:,115,115#msg-115
spyke01 wrote on 2010-10-18:
That did it thanks!
santi900 wrote on 2010-10-19:
Hi again,

i have readed all threads about it, but i can not try !!. I am generating a html with dynamics graphics. The graphs for this are gif of 1 pixel width and with a value as parameter i make this size wider.

The container column width is fixed and the pdf respects it, but the img, I am aplying the factor you explain in this thread and they always has the same size and oversize in the pdf.

<tr ><td width="50" align="right" class="pregunta">1144</td><td width="200" class="pregunta">	
	<img src="./img/verde.gif"  height="10" width="173"></td></tr>
<tr ><td width="50" align="right" class="pregunta">1153</td><td width="200" class="pregunta">	
	<img src="./img/verde.gif"  height="10" width="176"></td></tr>

Any ideas? Thanks, best regards
support wrote on 2010-10-19:
Please, could you either send your html code to, or post an URL if it is publicly available?
santi900 wrote on 2010-10-19:
It is a intranet that requires auth, but if can show you all the necesary.

A php page calls a function that draw a graphic. It passes the param nota (it means score):

echo "<td width=\"200\" class=\"arean\">";
				echo "</td>";

The function grafico is this. Depending on valor it draws a red, yellow or red img and the width:

function grafico ($valor) {

	if ($valor<=2) {
	} elseif ($valor>3) {
	} else  {
	if ($valor!="")  {
		$ancho= $valor;
	<img alt="grf" src="./img/<?php echo $color;?>"  height="10" width="<?php echo $ancho;?>">

In this link you can see an image sample:

Note that the origin images have a width of 1 px and via code i modify this width.

Well, it builds the pages, but at same time i save the result as html

At the begin of script:


At the end of script

$HtmlCode= ob_get_contents();
if (isset($_SESSION['htmlpdf'])) {

It caches the result in a session variable.

I make the print via link a php script:

<a class="param" href="pdfprint.php">PDF</a>

And the pdfrpint.php is this:

require 'pdfcrowd.php';
if (isset($_SESSION['htmlpdf'])) {
	//i save the result of the buffered document in a file
	file_put_contents("pdf.html", $html);
	$client = new Pdfcrowd("my", "mine");
		header('Content-type: application/pdf');
        	header('Content-Disposition: attachment; filename="impresion.pdf"');
		echo $client->convertURI('');
	catch(PdfcrowdException $e)
	    echo $e->getMessage();

Thats all, it works fine, i have not problem about authentiifcate to a external site (yours)... but the graphics overflows, as showed in this link and does not respect width:

I hope you have all necessary information.

Thank you very much.

support wrote on 2010-10-19:
Thanks for the info. We tried to replicate your issue, but with no luck.

It would be best if you could save that page in a browser and send us the generated html (plus that one-pixel image) so we can look at it.
support wrote on 2010-10-21:
It should be fixed now. Can you check please?
santi900 wrote on 2010-10-21:
It works perfectly. Thank you. regards