PHPOffice / PHPPresentation

A pure PHP library for reading and writing presentations documents
https://phpoffice.github.io/PHPPresentation
Other
1.3k stars 519 forks source link

How to convert file pptx to pdf file #725

Open duongsieu opened 1 year ago

duongsieu commented 1 year ago

I am doing the conversion of pptx files to pdf using the PhpPresentation library, but it seems that the library does not support this yet, my code:

public static function convertFilePptxToPdf($file, $nameFile)
    {
        //Load pptx file
        $reader = \PhpOffice\PhpPresentation\IOFactory::createReader("PowerPoint2007");
        $spreadsheet = $reader->load($file);
        //Save it into PDF
        $PDFWriter = \PhpOffice\PhpPresentation\IOFactory::createWriter($spreadsheet, 'Dompdf');
        $PDFWriter->save(storage_path('app/public/files/' . $nameFile));
        return $nameFile;
    }
IvanSerevko commented 1 year ago

use ncjoes/office-converter

$converter = new OfficeConverter($fullPath, $fullTmpDirPath); $pdfFile = $converter->convertTo('pdf_name');

sxaxmz commented 1 year ago

@IvanSerevko This workaround is not valid, as there is an issue with using the library as the ConvertTo function returns an error. Reference ncjose #46.