How to convert PDF to image using PHP by API?

Question:I want to convert the PDF to image through PHP by API but when the output image generated it's get blur from original.I use some application in the market. Blur image is not what I want, so I guess is there any solution on VeryPDF?

Answer: When you need to convert PDF to image through PHP by API, maybe you can have a free trial of VeryPDF cloud based application named PDF to Image Converter Cloud API, by which we can convert PDF to image like JPG, PNG, normal TIFF, Faxable TIFF, GIF, TGA, PCX, BMP, etc. images.  And VeryPDF cloud based application can be called from any platform and any program languages, include C#, VB.NET, ASP.NET, ASP, PHP, Java, Ruby, Amazon, etc. And the output will not be blur. Please check more information of this software on homepage, in the following part, I will show you how to use this software.

Step 1. Convert PDF to image from PHP

  • By VeryPDF cloud based application, you do not need to download any application. As we have installed related software on our server, all you need to do is that open browser and inputting URL like the following:
  • Convert PDF file to black and white TIFF file, at 300 DPI, without dither option,
    http://online.verypdf.com/api/?apikey=XXXX&app=pdftools&infile=http://online.verypdf.com/examples/cloud-api/verypdf2.pdf&outfile=verypdf.tif&-f=1&-l=1&-r=300&-forcebwtif&-threshold=200
    By the above URL, we can convert PDF file to black and white TIFF file and set resolution as 300 DPI without dithering. Meanwhile by this application, we can specify conversion page range like, if you need to only convert the first page of PDF, please add parameter &-f=1&-l=1 like this.
    -f <int>                      : first page to convert
    -l <int>                      : last page to convert
    -pagerange <string>           : set page range
    Please check more parameters on the user manual. There are too many, I can not list all of them here.

  • When you need to call it from PHP code, all you need to do is simply add the above URL to PHP code then you can run the conversion. Here is an example for your reference:
  • <?php
    //The Code
    /* gets the data from a URL */
    function get_data($url)
    {
        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }

    //The Usage
    $returned_content = get_data('http://online.verypdf.com/api/?apikey=XXXX&app=pdftools&infile=http://online.verypdf.com/examples/cloud-api/verypdf2.pdf&outfile=verypdf.jpg&-f=1&-l=1&-width=300&-height=600');
    echo $returned_content;
    ?>

By this API, we can convert PDF to image from PHP code easily. Now let us check the conversion effect from the following snapshot. During the using, if you have any question, please contact us as soon as possible.

input PDF and output image

VN:F [1.9.20_1166]
Rating: 6.7/10 (12 votes cast)
VN:F [1.9.20_1166]
Rating: -1 (from 5 votes)
How to convert PDF to image using PHP by API?, 6.7 out of 10 based on 12 ratings

Related Posts

This entry was posted in VeryPDF Cloud API and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!