0

I have a problem with my php: when I make conversion PDF to JPG not shown correctly.

This is the original pictures of pdf - > http://s16.postimg.org/ma0jizgt1/text_problem2_fw.png

This is the jpg after converting with imagick - > http://s14.postimg.org/ilhs9tt3l/text_problem_fw.png

Please can you help me ?

Thank you

PHP:

if (move_uploaded_file( $_FILES["files"]["tmp_name"], $uploadUrlPdf . $_FILES["files"]["name"]))
{

    $_FILES['files']['name'];
    $nr_pag = $_POST['nr_pagini'];

    for($i = 0; $i < $nr_pag; $i++)
    {

        $fn = $uploadUrlSwf.sprintf("%02d", "$i").".jpg";

        if (!file_exists($fn)) 
        {
            $im = new imagick();

            $im->setResolution($dpi,$dpi);
            $pdf = $uploadUrlPdf.$_FILES['files']['name']."[$i]";
            $im->readimage($pdf); 

            $im->setImageFormat('jpg');
            $im->writeImage($fn);
            file_put_contents( $fn, (string)$im );
            $im->clear(); 
            $im->destroy();
        }

    }
}
else
{     
    echo "error!";
}
George G
  • 7,443
  • 12
  • 45
  • 59
  • It's possible you're using a version of ImageMagick (or rather Ghostscript) that has a bug in it http://stackoverflow.com/questions/23085550/php-imagick-pdf-conversion-text-aliasing/23144243#23144243 – Danack Sep 23 '14 at 16:14

1 Answers1

0

Try setting your dpi value higher. If that does not work, try another export format (other than jpg). SVG would be your best bet, because you can scale that while the text and other shapes are still perfect quality. JPG wil not be sharp at a high zoom level if the resolution (dpi) is too low.

This forum entry might help: anti-aliased text when exporting PDF to image

Smile4ever
  • 3,491
  • 2
  • 26
  • 34