#spatie pdf to image

3 messages · Page 1 of 1 (latest)

thick obsidian
#

Call to undefined method Spatie\PdfToImage\Pdf::setCompressionQuality()

terse tendon
#

Okay, so what's the code you're using? What version of the package do you have installed? What's the stack trace?
Help us help you, nobody can really help you if you don't provide any information

thick obsidian
# terse tendon Okay, so what's the code you're using? What version of the package do you have i...
public function convert(string $file, Conversion $conversion = null): string
    {
        $path = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME);
        $pathFilePdf = $path.'.pdf';
        $pathToImageFile = $path.'.jpg';
        $domPdfPath = base_path('vendor/dompdf/dompdf');
        $settings = new Settings();
        $settings->setPdfRendererPath($domPdfPath);
        $settings->setPdfRendererName('DomPDF');
        $filedocx= IOFactory::load($file); 
        $convert = IOFactory::createWriter($filedocx, 'PDF');
        $convert->save($pathFilePdf);
        $pageNumber = $conversion ? $conversion->getPdfPageNumber() : 1;
        $pdf = new Pdf($pathFilePdf);
        $pdf->setCompressionQuality(100); 
        $pdf->setPage($pageNumber)->saveImage($pathToImageFile);
        unlink($pathFilePdf);
        return $pathToImageFile;
    }
    "spatie/pdf-to-image": "^1.2"
    "php":^8.1
```I use the spatie media library to convert pdf to image, using the image generator