I wonder if there is a possibility of converting a Word file (.doc, .docx) to a .pdf file using Php or JavaScript (or something like that). For example, the user uploads a .docx file that should be saved only in .pdf format - to do the conversion.
I wonder if there is a possibility of converting a Word file (.doc, .docx) to a .pdf file using Php or JavaScript (or something like that). For example, the user uploads a .docx file that should be saved only in .pdf format - to do the conversion.
Requires: link
You can use link , you should install via composer:
composer require gears/pdf:*
Then on your composer.json
add:
"scripts":
{
"post-install-cmd": ["PhantomInstaller\Installer::installPhantomJS"],
"post-update-cmd": ["PhantomInstaller\Installer::installPhantomJS"]
}
Then after uploading select:
<?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');
You can use the link that supports several formats:
You should install via composer:
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');