Skip to content

v3.0.0 20240226 #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9b35e8c
pdfjs: Import Mozilla pdf.js
Nicklas373 Feb 21, 2024
e8213f8
assets: Update new assets
Nicklas373 Feb 21, 2024
b965920
Treewide: Controllers: Major update
Nicklas373 Feb 21, 2024
eb02fdf
Database: Update database schema
Nicklas373 Feb 21, 2024
69f2e94
Routes: Update new route
Nicklas373 Feb 21, 2024
9e6808a
resources: views: Design all custom error pages
Nicklas373 Feb 21, 2024
672a2be
Treewide: resources: views: Major updates
Nicklas373 Feb 21, 2024
122f6b9
resources: css: Update internal css
Nicklas373 Feb 21, 2024
a5542d9
ext-js: kao-main: Adapt for new features
Nicklas373 Feb 21, 2024
14e922d
kao-logic: Major updates
Nicklas373 Feb 21, 2024
9458259
ext-php: Drop unused module
Nicklas373 Feb 21, 2024
0dca469
ext-python: Misc updates
Nicklas373 Feb 21, 2024
3f3a4a6
App: Exceptions: Configure error route
Nicklas373 Feb 21, 2024
8c5c23a
Treewide: Major dependency and versioning updates
Nicklas373 Feb 21, 2024
1ffb0b3
Treewide: Update prebuilt library
Nicklas373 Feb 21, 2024
65f31d1
Treewide: Minor changes
Nicklas373 Feb 23, 2024
25cdc97
Treewide: Fix with case-sensitive issue
Nicklas373 Feb 24, 2024
f5586bc
resources: Fixup case-sensitive issue
Nicklas373 Feb 24, 2024
79779fc
assets: Temporary drop assets
Nicklas373 Feb 24, 2024
8178ade
assets: Hello asset
Nicklas373 Feb 24, 2024
6e1740c
Resources: again... case sensitive
Nicklas373 Feb 24, 2024
66838f9
assets: Dunno
Nicklas373 Feb 24, 2024
5155746
assets: Restore dunno
Nicklas373 Feb 24, 2024
68b4bd8
Docker: Update container image
Nicklas373 Feb 26, 2024
4348230
Assets: Update static library
Nicklas373 Feb 26, 2024
7e5aca9
composer: Update dependencies
Nicklas373 Feb 26, 2024
3a636f2
Treewide: Fix inconsistencies layout composition
Nicklas373 Feb 26, 2024
4f7f076
kao-logic: Fix cnvFrPDF logic
Nicklas373 Feb 26, 2024
280e504
Treewide: Adapt some sources
Nicklas373 Feb 26, 2024
4fc18d0
Controllers: Convert: Fixup python init
Nicklas373 Feb 26, 2024
1369156
Docker: Update container environment
Nicklas373 Feb 26, 2024
4020f20
Resources: Update static library
Nicklas373 Feb 26, 2024
84f95fa
README: Updated documentation
Nicklas373 Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 30 additions & 11 deletions Dockerfile/Dockerfile.hana-app-pdf.sit
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM php:8.2-fpm

# Configure image maintainer
LABEL maintainer="Nicklas373 <[email protected]>"
LABEL version="1.2"
LABEL version="1.3"
LABEL description="Docker application image for HANA-CI SIT"

# Configure ARG
Expand Down Expand Up @@ -40,7 +40,23 @@ WORKDIR /var/www/html
RUN apt-get update && apt-get install -y \
curl \
unzip \
git
git \
libmagickwand-dev \
libzip-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
ghostscript

# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) \
gd \
zip

# Install Imagick extension
RUN pecl install imagick && \
docker-php-ext-enable imagick

# Configure PostgresSQL PHP Driver
RUN apt-get update && apt-get install -y libpq-dev && \
Expand All @@ -55,12 +71,14 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
RUN cd hanaci-pdf && composer install --no-interaction --no-scripts --no-progress --prefer-dist

# Configure App Service
RUN mkdir hanaci-pdf/storage/app/public/temp
RUN mkdir hanaci-pdf/storage/app/public/temp-merge
RUN mkdir hanaci-pdf/storage/app/public/temp-image
RUN mkdir hanaci-pdf/storage/app/public/upload-pdf
RUN cd hanaci-pdf && cp .env.example .env
RUN mkdir hanaci-pdf/storage/app/public/batch
RUN mkdir hanaci-pdf/storage/app/public/download
RUN mkdir hanaci-pdf/storage/app/public/image
RUN mkdir hanaci-pdf/storage/app/public/pool
RUN mkdir hanaci-pdf/storage/app/public/upload
RUN cd hanaci-pdf && mv .env.example .env
RUN cd hanaci-pdf && chmod o+w /var/www/html/hanaci-pdf/storage/ -R
RUN cd hanaci-pdf && chmod o+w /var/www/html/hanaci-pdf/vendor/mpdf/mpdf/tmp/ -R
RUN cd hanaci-pdf && php artisan key:generate
RUN cd hanaci-pdf && php artisan storage:link
RUN cd hanaci-pdf && php artisan config:cache
Expand All @@ -84,7 +102,8 @@ RUN cd hanaci-pdf && echo "FTP_SERVER=$FTP_SERVER" >> .env
RUN cd hanaci-pdf && echo "FTP_ROOT=$FTP_ROOT" >> .env
RUN cd hanaci-pdf && echo "ILOVEPDF_PUBLIC_KEY=$ILOVEPDF_PUBLIC_KEY" >> .env
RUN cd hanaci-pdf && echo "ILOVEPDF_SECRET_KEY=$ILOVEPDF_SECRET_KEY" >> .env
RUN cd hanaci-pdf && echo "ILOVEPDF_EXT_IMG_DIR=temp-image" >> .env
RUN cd hanaci-pdf && echo "PDF_MERGE_TEMP=temp-merge" >> .env
RUN cd hanaci-pdf && echo "PDF_UPLOAD=upload-pdf" >> .env
RUN cd hanaci-pdf && echo "PDF_DOWNLOAD=temp" >> .env
RUN cd hanaci-pdf && echo "PDF_IMG_POOL=image" >> .env
RUN cd hanaci-pdf && echo "PDF_BATCH=batch" >> .env
RUN cd hanaci-pdf && echo "PDF_UPLOAD=upload" >> .env
RUN cd hanaci-pdf && echo "PDF_DOWNLOAD=download" >> .env
RUN cd hanaci-pdf && echo "PDF_POOL=pool" >> .env
2 changes: 2 additions & 0 deletions Dockerfile/Dockerfile.hana-instance.sit
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ RUN apt-get update \
php8.2-ldap \
php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole \
php8.2-memcached php8.2-pcov php8.2-xdebug \
php8.2-imagick \
ghostscript \
&& curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \
&& apt-get update \
&& apt-get -y autoremove \
Expand Down
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## HANA PDF
HANA PDF is a __Laravel__ based project powered by front-end framework like __ViteJS__ and __Tailwind CSS__ and used of __Flowbite__ library to maintain responsive and materialize interface. And with integration from __iLovePDF__ and __Aspose Cloud__ API as one of the back-end, it have feature to merge, split, compress, convert, and add watermarks to PDF documents, that can handle easily and quickly.

<br>
<div style="text-align: center;">
<img src="screenshot/logo.png" alt="HANA" width="300" height="300">
</div>
<br>

__HANA PDF__ is your go-to solution for effortlessly managing your PDFs. We've designed it with simplicity in mind, so you can edit,
combine, shrink, convert, and personalize your PDFs with just a few clicks. And was implemented with front-end framework like ViteJS and Tailwind CSS and used of Flowbite library to maintain responsive and materialize interface. And powered with iLovePDF and Aspose Cloud API as one of the back-end.

---

Expand All @@ -14,11 +22,9 @@ HANA PDF is a __Laravel__ based project powered by front-end framework like __Vi
* On Windows use Docker Desktop
* On Linux use docker-compose and docker.io
- [Node JS 20.11](https://nodejs.org/en)
- [Flowbite](https://flowbite.com/)
- [PHP 8.2.12](https://www.php.net/downloads.php)
- [PostgreSQL 16.2](https://www.postgresql.org/)
- [Python 3.10.x](https://www.python.org/downloads/release/python-31011/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Vite JS](https://vitejs.dev/)

---
Expand Down Expand Up @@ -84,10 +90,11 @@ HANA PDF is a __Laravel__ based project powered by front-end framework like __Vi
- ILOVEPDF_ENC_KEY="ILOVEPDF_ENC_KEY" [Generate your hash key (Max. 25 digits)]
- ILOVEPDF_PUBLIC_KEY="ILOVEPDF_PUBLIC_KEY" [https://developer.ilovepdf.com/]
- ILOVEPDF_SECRET_KEY="ILOVEPDF_SECRET_KEY" [https://developer.ilovepdf.com/]
- ILOVEPDF_EXT_IMG_DIR="temp-image"
- PDF_MERGE_TEMP="temp-merge"
- PDF_UPLOAD="upload-pdf"
- PDF_DOWNLOAD="temp"
- PDF_IMG_POOL="image"
- PDF_BATCH="batch"
- PDF_UPLOAD="upload"
- PDF_DOWNLOAD="download"
- PDF_POOL="pool"
- TELEGRAM_BOT_ID="YOUR_TELEGRAM_BOT_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
- TELEGRAM_CHAT_ID="YOUR_TELEGRAM_CHANNEL_ID" [https://telegram-bot-sdk.com/docs/getting-started/installation]
- TOKEN_GENERATE="YOUR_ENCODE_SHA512_TOKEN"
Expand All @@ -100,10 +107,11 @@ HANA PDF is a __Laravel__ based project powered by front-end framework like __Vi
- php artisan migrate
```
5. Create new directory inside storage/app/public
- temp
- temp-image
- temp-merge
- upload-pdf
- image
- batch
- upload
- download
- pool
6. Start to deploy
```bash
- npm run dev -- --host
Expand All @@ -115,17 +123,20 @@ HANA PDF is a __Laravel__ based project powered by front-end framework like __Vi
### Technology Stack
- [Aspose](https://www.aspose.cloud/)
- [Docker](https://www.docker.com/)
- [DropzoneJS](https://www.dropzone.dev/)
- [Flowbite](https://flowbite.com/)
- [iLovePDF](https://developer.ilovepdf.com/)
- [Node JS](https://nodejs.org/en)
- [PDFJS](https://mozilla.github.io/pdf.js/)
- [PHPOffice](https://github.com/PHPOffice)
- [Python](https://www.python.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Vite JS](https://vitejs.dev/)

---

### License
The HANA-CI PDF is a open source Laravel Project that has licensed under the [MIT license](https://opensource.org/licenses/MIT).
The HANA PDF is a open source Laravel Project that has licensed under the [MIT license](https://opensource.org/licenses/MIT).

---

Expand Down
4 changes: 2 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function render($request, Throwable $exception)
Log::error('Query Exception failed with: '. $e->getMessage());
}
}
abort(404);
abort(403);
} else if ($exception instanceof TokenMismatchException || ($exception instanceof HttpException && $exception->getStatusCode() == 419)) {
$message = 'TokenMismatchException: ' . $exception->getMessage();
NotificationHelper::Instance()->sendRouteErrNotify($uuid, 'FAIL', 'Token Mismatch exception!', $currentRouteInfo, $message, $userIp);
Expand All @@ -96,7 +96,7 @@ public function render($request, Throwable $exception)
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
}
abort(419);
abort(401);
}
return parent::render($request, $exception);
}
Expand Down
93 changes: 93 additions & 0 deletions app/Http/Controllers/main/thumbnailController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace App\Http\Controllers\main;

use App\Helpers\AppHelper;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use PhpOffice\PhpWord\IOFactory as WordIOFactory;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpSpreadsheet\IOFactory as SpreadsheetIOFactory;
use PhpOffice\PhpPresentation\IOFactory as PresentationIOFactory;
use Spatie\PdfToImage\Pdf;
use Mpdf\Mpdf;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ZipArchive;

class thumbnailController extends Controller
{
public function getThumbnail(Request $request)
{
$validator = Validator::make($request->all(), [
'file' => 'required'
]);

$uuid = AppHelper::Instance()->get_guid();

if ($validator->fails()) {
$errors = $validator->errors()->all();
return response()->json([
'status' => 401,
'message' => 'Thumbnail generate failed !',
'error' => $errors,
'processId' => null
], 401);
} else {
if ($request->has('file')) {
$files = $request->post('file');
$pdfThumbnail_Location = env('PDF_IMG_POOL');
$pdfUpload_Location = env('PDF_UPLOAD');
$pdfPool_Location = env('PDF_POOL');
$currentFileName = basename($files);
$pdfFileName = str_replace(' ', '_', $currentFileName);
$pdfRealExtension = pathinfo($pdfFileName, PATHINFO_EXTENSION);
$newFilePath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfFileName);
$thumbnailFilePath = Storage::disk('local')->path('public/'.$pdfThumbnail_Location.'/'.$pdfFileName.'.png');
try {
Settings::setPdfRendererPath(base_path('vendor/mpdf/mpdf'));
Settings::setPdfRendererName('MPDF');

$pdfPath = Storage::disk('local')->path('public/'.$pdfPool_Location.'/'.$pdfFileName);
if ($pdfRealExtension == 'docx' || $pdfRealExtension == 'doc') {
$phpWord = WordIOFactory::load($newFilePath);
$phpWord->save($pdfPath, 'PDF');
} else if ($pdfRealExtension == 'xls' || $pdfRealExtension == 'xlsx') {
$phpXlsx = SpreadsheetIOFactory::load($newFilePath);
$phpXlsx->setActiveSheetIndex(0);
$phpXlsxWriter = SpreadsheetIOFactory::createWriter($phpXlsx, 'Mpdf');
$phpXlsxWriter->save($pdfPath);
} else {
return response()->json([
'status' => 400,
'message' => 'Failed to generate thumbnail !',
'error' => 'Invalid or unsupported file extension: '.$pdfRealExtension,
'processId' => null
], 400);
}
$pdf = new Pdf($pdfPath);
$pdf->setPage(1)
->saveImage($thumbnailFilePath);

return response()->json([
'status' => 200,
'message' => 'OK',
'res' => Storage::disk('local')->url(env('PDF_IMG_POOL').'/'.$pdfFileName.'.png'),
'fileName' => $pdfFileName,
'error' => null,
'processId' => null
], 200);
} catch (Exception $e) {
return response()->json([
'status' => 400,
'message' => 'Failed to generate thumbnail !',
'error' => $pdfFileName.' could not generate thumbnail with error: '.$e->getMessage(),
'processId' => null
], 400);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\main;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
Expand Down
Loading