環境
centos 7
php 7.0
yumやcomposerはinstall済みとします
composer.json
composer.jsonを用意
{
"require": {
"phpoffice/phpword": "dev-master",
"gears/pdf":"*"
},
"scripts":
{
"post-install-cmd": ["PhantomInstaller\\Installer::installPhantomJS"],
"post-update-cmd": ["PhantomInstaller\\Installer::installPhantomJS"]
}
}
cmdでの作業
$yum -y install libreoffice libreoffice-langpack-ja
$yum -y install php-pecl-zip.x86_64
$composer install #composer.jsonがあるディレクトリで行う
変換処理を行うphpを作る
convert.php
<?php
require './vendor/autoload.php';
Gears\Pdf::convert('./test.docx', './test.pdf');
※ test.docxは適当なテスト用のwordファイルです
convert.phpを実行すれば完了!
dockerで起動する
参考文献
https://packagist.org/packages/gears/pdf
https://www.ka-net.org/blog/?p=6952