Jump to content

Change PDF invoice image (logo) size


Recommended Posts

I red a lot about customization of PDF invoice, since the basic properties are not safisty.

 

I just need to put the seller information to the header.

 

I consider the simplest solution is to substitute the company logo by logo with company information. However the process is not so easy, since you have set the maximum height of invoice logo to 72 px (I suppose), so the invoice logo with seller information looks like the attachment. So I tried to change the 72 px limit in fpdf.php

Original piece of code:

if($unit=='pt')
	$this->k=1;
elseif($unit=='mm')
	$this->k=72/25.4;
elseif($unit=='cm')
	$this->k=72/2.54;
elseif($unit=='in')
	$this->k=72;

Substitute:

if($unit=='pt')
	$this->k=1;
elseif($unit=='mm')
	$this->k=235/82.9;
elseif($unit=='cm')
	$this->k=235/8.29;
elseif($unit=='in')
	$this->k=235;

 

However, the result is still the same, like in the attached image.

 

Is this right way? If so, why is it still the same size?

 

Does anybody have any point?

post-282359-0-98003500-1315242079_thumb.png

Link to comment
Share on other sites

  • 3 months later...

I know this is old, but I've found myself adjusting the size of the logo myself and I think you're adjusting it in the wrong place. Prestashop doesn't limit the height to 72pixels, what you see happening is the PDF generator is changing the logo to 72 DPI.

 

If you want to adjust the size of the logo, override the header() function in the PDF.php class. around the middle of the function you'll find some code like this:

 

if (file_exists(_PS_IMG_DIR_.'/logo_invoice.jpg'))
  $this->Image(_PS_IMG_DIR_.'/logo_invoice.jpg', 10, 8, 0, 15);

 

the last two params in the function allow you to scale the logo. If you want it bigger, change that 15 to a larger number such as 30. I'm not sure exactly what unit is being used but that's the easy solution to the answer for adjusting the size of the logo in your PDF.

 

Justin

Link to comment
Share on other sites

  • 3 months later...
  • 11 months later...

I know this is old, but I've found myself adjusting the size of the logo myself and I think you're adjusting it in the wrong place. Prestashop doesn't limit the height to 72pixels, what you see happening is the PDF generator is changing the logo to 72 DPI.

 

If you want to adjust the size of the logo, override the header() function in the PDF.php class. around the middle of the function you'll find some code like this:

 

if (file_exists(_PS_IMG_DIR_.'/logo_invoice.jpg'))
  $this->Image(_PS_IMG_DIR_.'/logo_invoice.jpg', 10, 8, 0, 15);

 

the last two params in the function allow you to scale the logo. If you want it bigger, change that 15 to a larger number such as 30. I'm not sure exactly what unit is being used but that's the easy solution to the answer for adjusting the size of the logo in your PDF.

 

Justin

 

 

Ok I looked also at

 if (file_exists(_PS_IMG_DIR_.'/logo_invoice.jpg'))
 {
  if ($this->_isPngFile(_PS_IMG_DIR_.'/logo_invoice.jpg'))
   $this->Image(_PS_IMG_DIR_.'/logo_invoice.jpg', 10, 8, 0, 15, 'PNG');
  else
   $this->Image(_PS_IMG_DIR_.'/logo_invoice.jpg', 10, 8, 0, 15);
 }
 elseif (file_exists(_PS_IMG_DIR_.'/logo.jpg'))
 {
  if ($this->_isPngFile(_PS_IMG_DIR_.'/logo.jpg'))
   $this->Image(_PS_IMG_DIR_.'/logo.jpg', 10, 8, 0, 15, 'PNG');
  else
   $this->Image(_PS_IMG_DIR_.'/logo.jpg', 10, 8, 0, 15);
 }

 

and could not size up my logo. I already moved a newer and bigger logo into /prestashop/img/logo_invoice.jpg with eg. 130pxx130px.

 

No changes appear :( Would be really great if I could make our logo bigger and perhaps if I could even add a header line with our company's name.

 

Can some one help me here`?

Link to comment
Share on other sites

Have you tried editing header.tpl in your pdf folder?

Starting around line 27 you will see this:

 

 

<td style="width: 50%">
 {if $logo_path}
  <img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />
 {/if}
</td>

 

Maybe try changing image src path to the image you made /prestashop/img/logo_invoice.jpg ?

Link to comment
Share on other sites

  • 1 year later...

There is a much simpler solution. I simply doubled the size of my logos footprint but retained the logo images size. I effectively added a bottom and right side border equal to the original logos size. Save the logo as a GIF with the background (added size) as transparent. Worked first time.

Link to comment
Share on other sites

I red a lot about customization of PDF invoice, since the basic properties are not safisty.

 

I just need to put the seller information to the header.

 

I consider the simplest solution is to substitute the company logo by logo with company information. However the process is not so easy, since you have set the maximum height of invoice logo to 72 px (I suppose), so the invoice logo with seller information looks like the attachment. So I tried to change the 72 px limit in fpdf.php

Original piece of code:

	if($unit=='pt')
		$this->k=1;
	elseif($unit=='mm')
		$this->k=72/25.4;
	elseif($unit=='cm')
		$this->k=72/2.54;
	elseif($unit=='in')
		$this->k=72;
Substitute:

	if($unit=='pt')
		$this->k=1;
	elseif($unit=='mm')
		$this->k=235/82.9;
	elseif($unit=='cm')
		$this->k=235/8.29;
	elseif($unit=='in')
		$this->k=235;
However, the result is still the same, like in the attached image.

 

Is this right way? If so, why is it still the same size?

 

Does anybody have any point?

 

 

What is your PrestaShop version? It looks like v1.4. Invoices are completely different from v1.5.

Link to comment
Share on other sites

×
×
  • Create New...