15

I have a 842 x 595 PDF, 72 dpi and i'm inserting a 1200x800 image, again with 72dpi.

scaleFactor is 1, imageScale is 1

in theory, my pdf should show part of the image (the first 842px). In reality the ratio is wrong, i have white space to the right and bottom.

I'm upgrading from FPDF and if i switch back to that it shows the picture ok.

$pdf = new TCPDF($this->orientation, 'pt', $this->format, true, 'UTF-8', false);
$pdf->setMargins(0, 0, -1, 1);
$pdf->setJPEGQuality(90);
$pdf->setImageScale(1);

$pdf->Image($image->path,0,0,0,0,'','','T',false, 72,'',false,false,0,'LT');

The sizes and scales all look fine if i dump the $pdf object...

Am i missing something?

Bobby Tables
  • 866
  • 1
  • 9
  • 18

4 Answers4

43
$pdf->SetAutoPageBreak(false, 0);

If someone is having the same problem, this is how i solved it. I hate it when i find people with the same exact problem i have and don't get back with the answer after they solved it.

Bobby Tables
  • 866
  • 1
  • 9
  • 18
-1

i agree with @Bobby Tables, so for that reason i will share what works for me... in my case i was looking for create a PDF in a personalized size (for print ID cards) for me the problem that i find was not in the code, was in the system, look, I had to set or create an profile or "New paper size" in the printer devices of windows, control panel/ hardware and sound / device and printer,... there select microsoft print to pdf, and now, in the superior navigation bar select "print server properties", in the open windows, click on "change form settings", and then, check "create a new form", now set the dimensión in inches, but in tcpdf the size is in "mm" millimeters, (you need to convert from mm to inches first), so put a name for the "new form or paper size", now save all, and restart the web browsers, ... go to your site and test it!,

now when you output you pdf to print just select the name of the "paper size" created by you, in advance tab, or more config options, and "there is" the size fit exact!....

Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26
  • Could you please format your answer, so what you are suggesting to do is more clear to see. – Constantin Beer Sep 02 '19 at 01:47
  • the original question was about TCPDF Image smaller than it should be? so my problem was the same, i fix all the code seting a new format of a page in TCPDF, but my print was in a diferent size... so i find other solution, setting the configuration of the pdf print devices in windows system... – Eduardo Rivera Digital Sep 02 '19 at 02:44
-3

i solved similar problem removing

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

from my code

AgelessEssence
  • 6,395
  • 5
  • 33
  • 37
-3

I got problem with displaying the image in correct size and the following code did the trick:

$pdf->setImageScale(1.53);

Hope it helps others.