diff --git a/.cache/fontconfig/0b714db9-87a9-406b-92ea-c24e421b56eb-le64.cache-7 b/.cache/fontconfig/0b714db9-87a9-406b-92ea-c24e421b56eb-le64.cache-7 new file mode 100644 index 0000000..86cbf72 Binary files /dev/null and b/.cache/fontconfig/0b714db9-87a9-406b-92ea-c24e421b56eb-le64.cache-7 differ diff --git a/.cache/fontconfig/31315a13-5402-4f5b-a9d7-64b2c1fecc2f-le64.cache-7 b/.cache/fontconfig/31315a13-5402-4f5b-a9d7-64b2c1fecc2f-le64.cache-7 new file mode 100644 index 0000000..e4d97e4 Binary files /dev/null and b/.cache/fontconfig/31315a13-5402-4f5b-a9d7-64b2c1fecc2f-le64.cache-7 differ diff --git a/.cache/fontconfig/36421361-e313-42e2-ad2b-a5e69ce56e9f-le64.cache-7 b/.cache/fontconfig/36421361-e313-42e2-ad2b-a5e69ce56e9f-le64.cache-7 new file mode 100644 index 0000000..0fb1da3 Binary files /dev/null and b/.cache/fontconfig/36421361-e313-42e2-ad2b-a5e69ce56e9f-le64.cache-7 differ diff --git a/.cache/fontconfig/3f56218c-51cf-4d29-9c62-a349d49a01ae-le64.cache-7 b/.cache/fontconfig/3f56218c-51cf-4d29-9c62-a349d49a01ae-le64.cache-7 new file mode 100644 index 0000000..04ef115 Binary files /dev/null and b/.cache/fontconfig/3f56218c-51cf-4d29-9c62-a349d49a01ae-le64.cache-7 differ diff --git a/.cache/fontconfig/564c0264-476d-4f68-a4ca-b60e2c0ae456-le64.cache-7 b/.cache/fontconfig/564c0264-476d-4f68-a4ca-b60e2c0ae456-le64.cache-7 new file mode 100644 index 0000000..0084af4 Binary files /dev/null and b/.cache/fontconfig/564c0264-476d-4f68-a4ca-b60e2c0ae456-le64.cache-7 differ diff --git a/.cache/fontconfig/5b00ac4f-b1e2-453e-b9d3-3e9746b28097-le64.cache-7 b/.cache/fontconfig/5b00ac4f-b1e2-453e-b9d3-3e9746b28097-le64.cache-7 new file mode 100644 index 0000000..49e2b3f Binary files /dev/null and b/.cache/fontconfig/5b00ac4f-b1e2-453e-b9d3-3e9746b28097-le64.cache-7 differ diff --git a/.cache/fontconfig/CACHEDIR.TAG b/.cache/fontconfig/CACHEDIR.TAG new file mode 100644 index 0000000..c6d9ccb --- /dev/null +++ b/.cache/fontconfig/CACHEDIR.TAG @@ -0,0 +1,4 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by fontconfig. +# For information about cache directory tags, see: +# http://www.brynosaurus.com/cachedir/ diff --git a/.cache/fontconfig/b2b40b91-3a57-407c-88c9-35042d285bb0-le64.cache-7 b/.cache/fontconfig/b2b40b91-3a57-407c-88c9-35042d285bb0-le64.cache-7 new file mode 100644 index 0000000..1465e94 Binary files /dev/null and b/.cache/fontconfig/b2b40b91-3a57-407c-88c9-35042d285bb0-le64.cache-7 differ diff --git a/.cache/fontconfig/bf3a0001-57f9-435b-9965-d6f9382d91df-le64.cache-7 b/.cache/fontconfig/bf3a0001-57f9-435b-9965-d6f9382d91df-le64.cache-7 new file mode 100644 index 0000000..9658770 Binary files /dev/null and b/.cache/fontconfig/bf3a0001-57f9-435b-9965-d6f9382d91df-le64.cache-7 differ diff --git a/.cache/fontconfig/c0f889b1-e49d-4847-9b27-7ba55f3aeecd-le64.cache-7 b/.cache/fontconfig/c0f889b1-e49d-4847-9b27-7ba55f3aeecd-le64.cache-7 new file mode 100644 index 0000000..ad7ad50 Binary files /dev/null and b/.cache/fontconfig/c0f889b1-e49d-4847-9b27-7ba55f3aeecd-le64.cache-7 differ diff --git a/.cache/fontconfig/c309b488-80d2-4bf7-a08f-e3718804fd67-le64.cache-7 b/.cache/fontconfig/c309b488-80d2-4bf7-a08f-e3718804fd67-le64.cache-7 new file mode 100644 index 0000000..041c47f Binary files /dev/null and b/.cache/fontconfig/c309b488-80d2-4bf7-a08f-e3718804fd67-le64.cache-7 differ diff --git a/.cache/fontconfig/c36a91f4-6931-401b-935c-2a2639565c86-le64.cache-7 b/.cache/fontconfig/c36a91f4-6931-401b-935c-2a2639565c86-le64.cache-7 new file mode 100644 index 0000000..e431adb Binary files /dev/null and b/.cache/fontconfig/c36a91f4-6931-401b-935c-2a2639565c86-le64.cache-7 differ diff --git a/.cache/fontconfig/eeea9ca5-90ff-440a-a49f-496d292566ea-le64.cache-7 b/.cache/fontconfig/eeea9ca5-90ff-440a-a49f-496d292566ea-le64.cache-7 new file mode 100644 index 0000000..78a5c78 Binary files /dev/null and b/.cache/fontconfig/eeea9ca5-90ff-440a-a49f-496d292566ea-le64.cache-7 differ diff --git a/.cache/fontconfig/fdbfd112-ee67-476e-8eb8-62d56a17384f-le64.cache-7 b/.cache/fontconfig/fdbfd112-ee67-476e-8eb8-62d56a17384f-le64.cache-7 new file mode 100644 index 0000000..5c3fd85 Binary files /dev/null and b/.cache/fontconfig/fdbfd112-ee67-476e-8eb8-62d56a17384f-le64.cache-7 differ diff --git a/_docker/app/Dockerfile b/_docker/app/Dockerfile index b5ce97d..a54310d 100755 --- a/_docker/app/Dockerfile +++ b/_docker/app/Dockerfile @@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y \ libzip-dev \ zip unzip \ git \ + ghostscript \ libmagickwand-dev --no-install-recommends && \ docker-php-ext-install bcmath gd zip && \ docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \ diff --git a/app/Http/Controllers/ConclusionController.php b/app/Http/Controllers/ConclusionController.php index 2a94be9..1fb52a9 100644 --- a/app/Http/Controllers/ConclusionController.php +++ b/app/Http/Controllers/ConclusionController.php @@ -86,6 +86,14 @@ class ConclusionController extends Controller $qrContent = route('qr.verify', ['type' => $cleanType, 'id' => $orderId]); $qrImage = QrCode::format('png')->size(150)->generate($qrContent); file_put_contents($qrPath, $qrImage); + chmod($qrPath, 0644); + } + + // Convert PDF to 1.4 compatible format so FPDI can parse any PDF version + $gsTmp = tempnam(sys_get_temp_dir(), 'gs_') . '.pdf'; + exec('gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOutputFile=' . escapeshellarg($gsTmp) . ' ' . escapeshellarg($tmpPath) . ' 2>/dev/null', $gsOut, $gsCode); + if ($gsCode === 0 && file_exists($gsTmp) && filesize($gsTmp) > 0) { + $tmpPath = $gsTmp; } $pdf = new Fpdi(); @@ -98,17 +106,12 @@ class ConclusionController extends Controller $pdf->AddPage($size2['orientation'], [$size2['width'], $size2['height']]); $pdf->useTemplate($tpl); - if ($i === 1) { - // First page: top-right, 30mm - $sz = 30; - $qrX = $size2['width'] - $sz - 18; - $qrY = 18; - } else { - // Other pages: bottom-right, 22mm, very bottom - $sz = 22; - $qrX = $size2['width'] - $sz - 8; - $qrY = $size2['height'] - $sz - 2; - } + // All pages: bottom-right corner, white background + $sz = 22; + $qrX = $size2['width'] - $sz - 8; + $qrY = $size2['height'] - $sz - 2; + $pdf->SetFillColor(255, 255, 255); + $pdf->Rect($qrX - 1, $qrY - 1, $sz + 2, $sz + 2, 'F'); $pdf->Image($qrPath, $qrX, $qrY, $sz, $sz); } @@ -125,19 +128,27 @@ class ConclusionController extends Controller $sizeCert = $pdf->getTemplateSize($tplCert); $pdf->AddPage($sizeCert['orientation'], [$sizeCert['width'], $sizeCert['height']]); $pdf->useTemplate($tplCert); - $pdf->Image($qrPath, $sizeCert['width'] - 22 - 8, $sizeCert['height'] - 22 - 2, 22, 22); // bottom-right + $cqX = $sizeCert['width'] - 22 - 8; + $cqY = $sizeCert['height'] - 22 - 2; + $pdf->SetFillColor(255, 255, 255); + $pdf->Rect($cqX - 1, $cqY - 1, 24, 24, 'F'); + $pdf->Image($qrPath, $cqX, $cqY, 22, 22); } } elseif (in_array($extCert, ['jpg', 'jpeg', 'png'])) { $pdf->AddPage('P', 'A4'); $pdf->Image($certPath, 0, 0, 210, 297); - $pdf->Image($qrPath, 210 - 22 - 8, 297 - 22 - 2, 22, 22); // bottom-right, inside frame + $pdf->SetFillColor(255, 255, 255); + $pdf->Rect(210 - 22 - 8 - 1, 297 - 22 - 2 - 1, 24, 24, 'F'); + $pdf->Image($qrPath, 210 - 22 - 8, 297 - 22 - 2, 22, 22); } } } $pdf->Output('F', $outputPath); } catch (\Exception $e) { - // If PDF manipulation fails, just copy the original + \Illuminate\Support\Facades\Log::error('ConclusionController PDF/QR failed: ' . $e->getMessage(), [ + 'order_id' => $orderId, 'type' => $orderType, 'file' => $e->getFile(), 'line' => $e->getLine(), + ]); copy($tmpPath, $outputPath); } } else { diff --git a/storage/app/public/attachments/auto_1/qr.png b/storage/app/public/attachments/auto_1/qr.png new file mode 100644 index 0000000..1610fc0 Binary files /dev/null and b/storage/app/public/attachments/auto_1/qr.png differ diff --git a/storage/app/public/attachments/auto_7896/97910615-dc80-4507-b692-85101c350bf2.pdf b/storage/app/public/attachments/auto_7896/97910615-dc80-4507-b692-85101c350bf2.pdf new file mode 100644 index 0000000..426a325 Binary files /dev/null and b/storage/app/public/attachments/auto_7896/97910615-dc80-4507-b692-85101c350bf2.pdf differ diff --git a/storage/app/public/attachments/auto_7896/9e66e886-2507-473e-abe7-53942027f5b2.pdf b/storage/app/public/attachments/auto_7896/9e66e886-2507-473e-abe7-53942027f5b2.pdf new file mode 100644 index 0000000..2161cbf Binary files /dev/null and b/storage/app/public/attachments/auto_7896/9e66e886-2507-473e-abe7-53942027f5b2.pdf differ diff --git a/storage/app/public/attachments/auto_7896/a2ca0905-adfd-4029-a74d-93d271c210a7.pdf b/storage/app/public/attachments/auto_7896/a2ca0905-adfd-4029-a74d-93d271c210a7.pdf new file mode 100644 index 0000000..513ba5a Binary files /dev/null and b/storage/app/public/attachments/auto_7896/a2ca0905-adfd-4029-a74d-93d271c210a7.pdf differ diff --git a/storage/app/public/attachments/auto_7896/b7503014-3f8b-456d-b09c-f386473b558b.pdf b/storage/app/public/attachments/auto_7896/b7503014-3f8b-456d-b09c-f386473b558b.pdf new file mode 100644 index 0000000..2161cbf Binary files /dev/null and b/storage/app/public/attachments/auto_7896/b7503014-3f8b-456d-b09c-f386473b558b.pdf differ diff --git a/storage/app/public/attachments/auto_7896/b86ec1b4-fb0c-4c30-ab58-f6a428502fc0.pdf b/storage/app/public/attachments/auto_7896/b86ec1b4-fb0c-4c30-ab58-f6a428502fc0.pdf new file mode 100644 index 0000000..34bde87 Binary files /dev/null and b/storage/app/public/attachments/auto_7896/b86ec1b4-fb0c-4c30-ab58-f6a428502fc0.pdf differ diff --git a/storage/app/public/attachments/auto_7896/fbdb970e-7054-4931-8b34-890e677d6b29.pdf b/storage/app/public/attachments/auto_7896/fbdb970e-7054-4931-8b34-890e677d6b29.pdf new file mode 100644 index 0000000..2161cbf Binary files /dev/null and b/storage/app/public/attachments/auto_7896/fbdb970e-7054-4931-8b34-890e677d6b29.pdf differ diff --git a/storage/app/public/attachments/auto_7896/qr.png b/storage/app/public/attachments/auto_7896/qr.png new file mode 100644 index 0000000..4f6a26b Binary files /dev/null and b/storage/app/public/attachments/auto_7896/qr.png differ diff --git a/storage/app/public/attachments/auto_9999/qr.png b/storage/app/public/attachments/auto_9999/qr.png new file mode 100644 index 0000000..48f4ab8 Binary files /dev/null and b/storage/app/public/attachments/auto_9999/qr.png differ