TCPDF poor image quality with jpeg and pngs

时间:2019-04-23 15:17:22

标签: php laravel tcpdf

I tried most of the suggestions at the below links (1.53 image scale and larger images)

tcpdf: poor image quality

TCPDF image quality issues

I am printing a 5x7 greeting card with a front, back, and inside image. The image source files are pngs/jpegs (tried both).

If you look at images below and PDF result; the PDF looks washed out.

CODE: (1.53 image scale in global config)

public function build_design(Design $design)
{
  PDF::SetTitle('Design');
  PDF::setJPEGQuality(100);
  PDF::AddPage();

  //Needed for images not being right size https://stackoverflow.com/questions/8135975/why-is-tcpdf-image-smaller-than-it-should-be
  PDF::SetAutoPageBreak(false, 0);

    if ($design->get_image_by_name('Back'))
    {
        PDF::Image($design->get_image_by_name('Back')->image,0,0,5,7);
    }

    if ($design->get_image_by_name('Front'))
    {
        PDF::Image($design->get_image_by_name('Front')->image,5,0,5,7);
    }

    if ($design->get_image_by_name('Inside'))
    {
        PDF::AddPage();
        PDF::Image($design->get_image_by_name('Inside')->image,0,0,10,7);
    }
}


public function print_design(Design $design)
{
    $this->build_design($design);
    PDF::Output('design.pdf');
}

RESULTING PDF:

https://www.dropbox.com/s/w10vq8q48m0ljtt/card.pdf?dl=0

FRONT: 1500x2100 300 dpi PNG

Front

INSIDE 3000x2100 300 dpi PNG

Inside

BACK: 1500x2100 300 dpi JPEG

Back

0 个答案:

没有答案