|
22 | 22 | use Ilovepdf\ImagepdfTask;
|
23 | 23 | use Ilovepdf\OfficepdfTask;
|
24 | 24 | use Ilovepdf\PdfjpgTask;
|
25 |
| -use Spatie\PdfToImage\Pdf; |
26 | 25 | use Symfony\Component\Process\Process;
|
27 | 26 | use Symfony\Component\Process\Exception\ProcessFailedException;
|
28 | 27 | use Symfony\Component\Process\Exception\RuntimeException;
|
@@ -507,43 +506,8 @@ public function convert(Request $request) {
|
507 | 506 | $minioUpload = Storage::disk('minio')->get($pdfUpload_Location.'/'.$currentFileName);
|
508 | 507 | file_put_contents(Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$currentFileName), $minioUpload);
|
509 | 508 | $newFilePath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$currentFileName);
|
510 |
| - try { |
511 |
| - $pdf = new Pdf($newFilePath); |
512 |
| - $pdfTotalPages = $pdf->pageCount(); |
513 |
| - Storage::disk('local')->delete('public/'.$pdfUpload_Location.'/'.$trimPhase1); |
514 |
| - } catch (\Exception $e) { |
515 |
| - $end = Carbon::parse(AppHelper::instance()->getCurrentTimeZone()); |
516 |
| - $duration = $end->diff($startProc); |
517 |
| - appLogModel::where('groupId', '=', $batchId) |
518 |
| - ->update([ |
519 |
| - 'errReason' => $e->getMessage(), |
520 |
| - 'errStatus' => 'Failed to count total PDF pages' |
521 |
| - ]); |
522 |
| - cnvModel::where('groupId', '=', $batchId) |
523 |
| - ->update([ |
524 |
| - 'result' => false, |
525 |
| - 'procEndAt' => AppHelper::instance()->getCurrentTimeZone(), |
526 |
| - 'procDuration' => $duration->s.' seconds' |
527 |
| - ]); |
528 |
| - NotificationHelper::Instance()->sendErrNotify( |
529 |
| - $currentFileName, |
530 |
| - $newFileSize, |
531 |
| - $batchId, |
532 |
| - 'FAIL', |
533 |
| - 'cnvToImg', |
534 |
| - 'Failed to count total PDF pages', |
535 |
| - $e->getMessage() |
536 |
| - ); |
537 |
| - Storage::disk('local')->delete('public/'.$pdfUpload_Location.'/'.$trimPhase1); |
538 |
| - return $this->returnDataMesage( |
539 |
| - 400, |
540 |
| - 'PDF Convert failed !', |
541 |
| - $e->getMessage(), |
542 |
| - $batchId, |
543 |
| - null, |
544 |
| - 'Failed to count total PDF pages' |
545 |
| - ); |
546 |
| - } |
| 509 | + $pdfTotalPages = AppHelper::instance()->count($newFilePath); |
| 510 | + Storage::disk('local')->delete('public/'.$pdfUpload_Location.'/'.$trimPhase1); |
547 | 511 | try {
|
548 | 512 | $ilovepdfTask = new PdfjpgTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY'));
|
549 | 513 | $ilovepdfTask->setFileEncryption($pdfEncKey);
|
|
0 commit comments