diff --git a/composer.json b/composer.json index d25406e..5366731 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "type": "project", "require": { "phpoffice/phpword": "dev-master", - "symfony/console": "7.2.x-dev" + "symfony/console": "7.2.x-dev", + "symfony/process": "7.2.x-dev" }, "autoload": { "psr-4": { @@ -20,4 +21,4 @@ } ], "minimum-stability": "dev" -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index a301122..466ce35 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "10a32976ced7d2c583fbadf2b55e4ca8", + "content-hash": "78a7f322da01fab9bc676d318e0f7a03", "packages": [ { "name": "phpoffice/math", @@ -705,6 +705,67 @@ ], "time": "2024-06-20T08:18:00+00:00" }, + { + "name": "symfony/process", + "version": "7.2.x-dev", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "bb0a8b7772610211c2cd7d6e4e36acfcbadcb613" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/bb0a8b7772610211c2cd7d6e4e36acfcbadcb613", + "reference": "bb0a8b7772610211c2cd7d6e4e36acfcbadcb613", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/7.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-07-29T06:33:22+00:00" + }, { "name": "symfony/service-contracts", "version": "dev-main", @@ -881,7 +942,8 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "phpoffice/phpword": 20 + "phpoffice/phpword": 20, + "symfony/console": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/dev.Dockerfile b/dev.Dockerfile index 9bf1e03..06a8eea 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,13 +1,23 @@ FROM php:8.2-cli # Install dependencies needed for Composer and PHP zip extension +RUN echo "deb http://deb.debian.org/debian bookworm contrib non-free" > /etc/apt/sources.list.d/contrib.list RUN apt-get update && apt-get install -y \ curl \ unzip \ libzip-dev \ + libreoffice \ + fontconfig \ + ttf-mscorefonts-installer \ && docker-php-ext-install zip \ && rm -rf /var/lib/apt/lists/* +# Install fonts +RUN mkdir -p /usr/share/fonts/truetype/custom +COPY ./fonts/gilroy/* /usr/share/fonts/truetype/custom +COPY ./fonts/lexend/* /usr/share/fonts/truetype/custom +RUN fc-cache -f -v + # Download and install Composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/examples/ebook_hasil.pdf b/examples/ebook_hasil.pdf index fd383ed..ef2116f 100644 Binary files a/examples/ebook_hasil.pdf and b/examples/ebook_hasil.pdf differ diff --git a/fonts/gilroy/Gilroy-Black.ttf b/fonts/gilroy/Gilroy-Black.ttf new file mode 100644 index 0000000..3e1a57e Binary files /dev/null and b/fonts/gilroy/Gilroy-Black.ttf differ diff --git a/fonts/gilroy/Gilroy-BlackItalic.ttf b/fonts/gilroy/Gilroy-BlackItalic.ttf new file mode 100644 index 0000000..6f0b4c4 Binary files /dev/null and b/fonts/gilroy/Gilroy-BlackItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-Bold.ttf b/fonts/gilroy/Gilroy-Bold.ttf new file mode 100644 index 0000000..1aea716 Binary files /dev/null and b/fonts/gilroy/Gilroy-Bold.ttf differ diff --git a/fonts/gilroy/Gilroy-BoldItalic.ttf b/fonts/gilroy/Gilroy-BoldItalic.ttf new file mode 100644 index 0000000..6754019 Binary files /dev/null and b/fonts/gilroy/Gilroy-BoldItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-ExtraBold.ttf b/fonts/gilroy/Gilroy-ExtraBold.ttf new file mode 100644 index 0000000..01eb343 Binary files /dev/null and b/fonts/gilroy/Gilroy-ExtraBold.ttf differ diff --git a/fonts/gilroy/Gilroy-ExtraBoldItalic.ttf b/fonts/gilroy/Gilroy-ExtraBoldItalic.ttf new file mode 100644 index 0000000..86000c1 Binary files /dev/null and b/fonts/gilroy/Gilroy-ExtraBoldItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-Heavy.ttf b/fonts/gilroy/Gilroy-Heavy.ttf new file mode 100644 index 0000000..726e371 Binary files /dev/null and b/fonts/gilroy/Gilroy-Heavy.ttf differ diff --git a/fonts/gilroy/Gilroy-HeavyItalic.ttf b/fonts/gilroy/Gilroy-HeavyItalic.ttf new file mode 100644 index 0000000..12a7e55 Binary files /dev/null and b/fonts/gilroy/Gilroy-HeavyItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-Light.ttf b/fonts/gilroy/Gilroy-Light.ttf new file mode 100644 index 0000000..b08db4e Binary files /dev/null and b/fonts/gilroy/Gilroy-Light.ttf differ diff --git a/fonts/gilroy/Gilroy-LightItalic.ttf b/fonts/gilroy/Gilroy-LightItalic.ttf new file mode 100644 index 0000000..ea4bee4 Binary files /dev/null and b/fonts/gilroy/Gilroy-LightItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-Medium.ttf b/fonts/gilroy/Gilroy-Medium.ttf new file mode 100644 index 0000000..06d6a94 Binary files /dev/null and b/fonts/gilroy/Gilroy-Medium.ttf differ diff --git a/fonts/gilroy/Gilroy-MediumItalic.ttf b/fonts/gilroy/Gilroy-MediumItalic.ttf new file mode 100644 index 0000000..9fbb898 Binary files /dev/null and b/fonts/gilroy/Gilroy-MediumItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-Regular.ttf b/fonts/gilroy/Gilroy-Regular.ttf new file mode 100644 index 0000000..ad17f71 Binary files /dev/null and b/fonts/gilroy/Gilroy-Regular.ttf differ diff --git a/fonts/gilroy/Gilroy-RegularItalic.ttf b/fonts/gilroy/Gilroy-RegularItalic.ttf new file mode 100644 index 0000000..628a732 Binary files /dev/null and b/fonts/gilroy/Gilroy-RegularItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-SemiBold.ttf b/fonts/gilroy/Gilroy-SemiBold.ttf new file mode 100644 index 0000000..cb3cbb6 Binary files /dev/null and b/fonts/gilroy/Gilroy-SemiBold.ttf differ diff --git a/fonts/gilroy/Gilroy-SemiBoldItalic.ttf b/fonts/gilroy/Gilroy-SemiBoldItalic.ttf new file mode 100644 index 0000000..fc82a10 Binary files /dev/null and b/fonts/gilroy/Gilroy-SemiBoldItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-Thin.ttf b/fonts/gilroy/Gilroy-Thin.ttf new file mode 100644 index 0000000..c6daeb7 Binary files /dev/null and b/fonts/gilroy/Gilroy-Thin.ttf differ diff --git a/fonts/gilroy/Gilroy-ThinItalic.ttf b/fonts/gilroy/Gilroy-ThinItalic.ttf new file mode 100644 index 0000000..4bc3561 Binary files /dev/null and b/fonts/gilroy/Gilroy-ThinItalic.ttf differ diff --git a/fonts/gilroy/Gilroy-UltraLight.ttf b/fonts/gilroy/Gilroy-UltraLight.ttf new file mode 100644 index 0000000..adc3e33 Binary files /dev/null and b/fonts/gilroy/Gilroy-UltraLight.ttf differ diff --git a/fonts/gilroy/Gilroy-UltraLightItalic.ttf b/fonts/gilroy/Gilroy-UltraLightItalic.ttf new file mode 100644 index 0000000..3403fe8 Binary files /dev/null and b/fonts/gilroy/Gilroy-UltraLightItalic.ttf differ diff --git a/fonts/lexend/Lexend-Black.ttf b/fonts/lexend/Lexend-Black.ttf new file mode 100644 index 0000000..2fea087 Binary files /dev/null and b/fonts/lexend/Lexend-Black.ttf differ diff --git a/fonts/lexend/Lexend-Bold.ttf b/fonts/lexend/Lexend-Bold.ttf new file mode 100644 index 0000000..95884f6 Binary files /dev/null and b/fonts/lexend/Lexend-Bold.ttf differ diff --git a/fonts/lexend/Lexend-ExtraBold.ttf b/fonts/lexend/Lexend-ExtraBold.ttf new file mode 100644 index 0000000..02f84ed Binary files /dev/null and b/fonts/lexend/Lexend-ExtraBold.ttf differ diff --git a/fonts/lexend/Lexend-ExtraLight.ttf b/fonts/lexend/Lexend-ExtraLight.ttf new file mode 100644 index 0000000..20e7068 Binary files /dev/null and b/fonts/lexend/Lexend-ExtraLight.ttf differ diff --git a/fonts/lexend/Lexend-Light.ttf b/fonts/lexend/Lexend-Light.ttf new file mode 100644 index 0000000..fb6d097 Binary files /dev/null and b/fonts/lexend/Lexend-Light.ttf differ diff --git a/fonts/lexend/Lexend-Medium.ttf b/fonts/lexend/Lexend-Medium.ttf new file mode 100644 index 0000000..d91a867 Binary files /dev/null and b/fonts/lexend/Lexend-Medium.ttf differ diff --git a/fonts/lexend/Lexend-Regular.ttf b/fonts/lexend/Lexend-Regular.ttf new file mode 100644 index 0000000..b423d3a Binary files /dev/null and b/fonts/lexend/Lexend-Regular.ttf differ diff --git a/fonts/lexend/Lexend-SemiBold.ttf b/fonts/lexend/Lexend-SemiBold.ttf new file mode 100644 index 0000000..9dcb821 Binary files /dev/null and b/fonts/lexend/Lexend-SemiBold.ttf differ diff --git a/fonts/lexend/Lexend-Thin.ttf b/fonts/lexend/Lexend-Thin.ttf new file mode 100644 index 0000000..0d7df88 Binary files /dev/null and b/fonts/lexend/Lexend-Thin.ttf differ diff --git a/src/.DS_Store b/src/.DS_Store index 5fb43a7..1b8618a 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/Command/Generate.php b/src/Command/Generate.php index b9d89c0..63a15c9 100644 --- a/src/Command/Generate.php +++ b/src/Command/Generate.php @@ -7,6 +7,8 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Process\Process; +use Symfony\Component\Process\Exception\ProcessFailedException; class Generate extends Command { @@ -23,13 +25,28 @@ class Generate extends Command { $inPath = $input->getArgument("input"); - $output->writeln(rootPath($inPath)); - $doc = new Ebook($inPath); $path = $doc->compile(); - // $output->writeln($path); + $cmd = new Process([ + "soffice", + "--headless", + "--convert-to", + "pdf", + "--outdir", + "storage/", + $path + ]); + + $cmd->run(); + + if (!$cmd->isSuccessful()) { + throw new ProcessFailedException($cmd); + } + + $output->writeln($cmd->getOutput()); + return Command::SUCCESS; } } diff --git a/src/Converter/Converter.php b/src/Converter/Converter.php deleted file mode 100644 index 6c8c50a..0000000 --- a/src/Converter/Converter.php +++ /dev/null @@ -1,5 +0,0 @@ -templateSource()); $proc->setValues([ - 'material' => $this->object->user_input->category, - 'chapter_name' => $this->object->user_input->material, + 'material' => strtoupper($this->object->user_input->category), + 'chapter_name' => strtoupper($this->object->user_input->material), 'chapter' => '01', ]); @@ -111,9 +111,7 @@ class Ebook implements Document $proc->cloneBlock('block_reflection#' . $ci, 0, true, false, $reflects); } - $proc->saveAs("./examples/ebook_hasil.docx"); - - return ""; + return $proc->save(); } protected function openFile(string $path) diff --git a/src/Template/.~lock.Ebook.docx# b/src/Template/.~lock.Ebook.docx# index 401d986..c6497a1 100644 --- a/src/Template/.~lock.Ebook.docx# +++ b/src/Template/.~lock.Ebook.docx# @@ -1 +1 @@ -,pande,pandewidya.local,15.08.2024 07:34,file:///Users/pande/Library/Application%20Support/LibreOffice/4; \ No newline at end of file +,pande,pandewidya.local,15.08.2024 10:30,file:///Users/pande/Library/Application%20Support/LibreOffice/4; \ No newline at end of file diff --git a/src/Template/Ebook.docx b/src/Template/Ebook.docx index 0abc3f0..4476e7c 100644 Binary files a/src/Template/Ebook.docx and b/src/Template/Ebook.docx differ diff --git a/src/Template/Ebook.pdf b/src/Template/Ebook.pdf deleted file mode 100644 index 3769ce9..0000000 Binary files a/src/Template/Ebook.pdf and /dev/null differ