1. Go to this page and download the library: Download ottosmops/pdftothumb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ottosmops / pdftothumb example snippets
\Ottosmops\Pdftothumb\Converter::create('/path/to/file.pdf')->convert();
//creates a thumb of the first page: '/path/to/file.jpg'
$exitCode = (new Converter($source, $target, $executable))->convert();
/*
* These generators will be used to created conversion of media files.
*/
'image_generators' => [
Spatie\MediaLibrary\ImageGenerators\FileTypes\Image::class ,
//Spatie\MediaLibrary\ImageGenerators\FileTypes\Pdf::class ,
Spatie\MediaLibrary\ImageGenerators\FileTypes\Svg::class ,
Spatie\MediaLibrary\ImageGenerators\FileTypes\Video::class ,
],
namespace App\ImageGenerators;
use Illuminate\Support\Collection;
use Spatie\MediaLibrary\Conversion\Conversion;
use Spatie\MediaLibrary\ImageGenerators\BaseGenerator;
use Ottosmops\Pdftothumb\Converter;
class Pdf extends BaseGenerator
{
/**
* This function should return a path to an image representation of the given file.
*/
public function convert(string $path, Conversion $conversion = null) : string
{
$imageFile = pathinfo($path, PATHINFO_DIRNAME).'/'.pathinfo($path, PATHINFO_FILENAME).'.jpg';
Converter::create($path)->target($imageFile)->convert();
return $imageFile;
}
public function
which pdftoppm
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.