phpgearbox/pdf
Requires: http://phantomjs.org
You can use the https://github.com/phpgearbox/pdf, shall install via Poser:
composer require gears/pdf:*
Then in his composer.json
add:
"scripts":
{
"post-install-cmd": ["PhantomInstaller\\Installer::installPhantomJS"],
"post-update-cmd": ["PhantomInstaller\\Installer::installPhantomJS"]
}
Then after upload select so:
<?php
require_once 'vendor/autoload.php';
//Upload vem aqui
\Gears\Pdf::convert('<caminho do documento>/documento.docx', '<caminho aonde será salvo o pdf>/documento.pdf');
Phpoffice/Phpword
You can use the https://github.com/PHPOffice/PHPWord which supports various formats:
- odt
- RTF
- Word2007
- HTML
- PDF
You must install via Poser:
composer require phpoffice/phpword
Example:
<?php
require_once 'vendor/autoload.php';
//Upload vem aqui
$source = '<caminho do documento>/documento.docx';
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');
$objWriter->save('<caminho aonde será salvo o pdf>/documento.pdf');
According to the documentation, it is necessary to install libreoffice in the case of phpgearbox. That’s msm?
– Renan Lopes
@Renanlopes libre-office-headless or unocon
– Guilherme Nascimento