From 049bf2a31749a9a10db3ca3130bfd0bb69ad0f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dicky=20Herlambang=20=28=E8=8A=B1=EF=BC=89?= Date: Wed, 6 Nov 2024 08:11:51 +0700 Subject: [PATCH] Controllers: Convert: Only use pdfCount() when file is PDF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dicky Herlambang (花) --- app/Http/Controllers/Api/Core/convertController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/Core/convertController.php b/app/Http/Controllers/Api/Core/convertController.php index 7b0ea0e6..b3e3d753 100644 --- a/app/Http/Controllers/Api/Core/convertController.php +++ b/app/Http/Controllers/Api/Core/convertController.php @@ -120,9 +120,11 @@ public function convert(Request $request) { $fileSize = filesize($newFilePath); $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); $procUuid = AppHelper::Instance()->generateUniqueUuid(cnvModel::class, 'processId'); - $pdf = new Pdf($newFilePath); - $pdfTotalPages = $pdf->pageCount(); $pdfNameWithExtension = pathinfo($currentFileName, PATHINFO_EXTENSION); + if ($pdfNameWithExtension == "pdf") { + $pdf = new Pdf($newFilePath); + $pdfTotalPages = $pdf->pageCount(); + } appLogModel::create([ 'processId' => $procUuid, 'groupId' => $batchId,