Google trends Public Holidays Coupon Code Code Compiler

Create Thumbnails of an existing PDF document

Apr 28, 2019

In most of the website for some reasons we have a option to upload a PDF file and create preview thumbnails from uploaded PDF file. So in this tutorial I will explain you how to create a PDF preview image in PHP.

PHP code

function get($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);
    return $data;

$response = get('');

$dr = explode(' ',$response);

$fileName1 = explode('/',str_replace("<br>","",$dr[1]));
// Get file name
$fileName = basename(end($fileName1));

$data = file_get_contents(str_replace("<br>","",$dr[1]));

// Upload thumbnails path
 $new = 't/'.$fileName;
 $upload =file_put_contents($new, $data);

Copyright 2024. All rights are reserved