Compare commits

...

2 Commits

Author SHA1 Message Date
pandeptwidyaop
28aa7507a6 Add fonts 2024-08-15 10:32:01 +08:00
pandeptwidyaop
163f97a67d add storage folder 2024-08-15 07:55:33 +08:00
41 changed files with 102 additions and 18 deletions

View File

@@ -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"
}
}

66
composer.lock generated
View File

@@ -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,

View File

@@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
src/.DS_Store vendored

Binary file not shown.

View File

@@ -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;
}
}

View File

@@ -1,5 +0,0 @@
<?php
namespace MenulisAi\Pdfgen\Converter;
class Converter {}

View File

@@ -24,8 +24,8 @@ class Ebook implements Document
$proc = new TemplateProcessor($this->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)

View File

@@ -1 +1 @@
,pande,pandewidya.local,15.08.2024 07:34,file:///Users/pande/Library/Application%20Support/LibreOffice/4;
,pande,pandewidya.local,15.08.2024 10:30,file:///Users/pande/Library/Application%20Support/LibreOffice/4;

Binary file not shown.

Binary file not shown.

1
storage/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*