���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/rickpfrv/public_html/weenclub/index.php
���ѧ٧ѧ�
<?php ob_start(); error_reporting(0); ini_set('display_errors', 0); require_once('libs/fpdf/fpdf.php'); require_once('libs/fpdi/src/autoload.php'); require_once('libs/tcpdf/tcpdf.php'); use setasign\Fpdi\Tcpdf\Fpdi; function isA4Portrait($w, $h) { return ($w >= 205 && $w <= 215) && ($h >= 290 && $h <= 302); } // Define two AABB regions for stacked A4 labels $aabbLabels = [ ['x' => 0, 'y' => 0, 'w' => 210, 'h' => 148.5], // Top half ['x' => 0, 'y' => 148.5, 'w' => 210, 'h' => 148.5], // Bottom half ]; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['pdfs'])) { $pdf = new Fpdi('P', 'mm', [105, 148]); // A6 $outputPath = __DIR__ . '/output_merged.pdf'; foreach ($_FILES['pdfs']['tmp_name'] as $index => $tmpFile) { if (!is_uploaded_file($tmpFile)) continue; try { $pageCount = $pdf->setSourceFile($tmpFile); for ($i = 1; $i <= $pageCount; $i++) { $tplId = $pdf->importPage($i); $size = $pdf->getTemplateSize($tplId); $w = $size['width']; $h = $size['height']; if (isA4Portrait($w, $h)) { foreach ($aabbLabels as $box) { $pdf->AddPage('P', [105, 148]); $pdf->StartTransform(); $pdf->Rotate(-90, 52.5, 74); // Rotate around A6 center $scale = 105 / $box['w']; // Fit cropped label width to A6 $scaledWidth = $box['w'] * $scale; $scaledHeight = $box['h'] * $scale; // 🔧 Fine-tuning adjustment $manualXShift = 0; $manualYShift = 0; $x = (105 - $scaledHeight) / -2 + $manualXShift; $y = $manualYShift; // 🧠 Actual crop with clipping $pdf->useImportedPage($tplId, $x, $y, $scaledWidth, 0, false, [ 'x' => $box['x'], 'y' => $box['y'], 'width' => $box['w'], 'height' => $box['h'] ]); $pdf->StopTransform(); } } else { $pdf->AddPage('P', [105, 148]); $pdf->useTemplate($tplId, 0, 0, 105, 148); } } } catch (Exception $e) { error_log("PDF processing error: " . $e->getMessage()); } } file_put_contents($outputPath, $pdf->Output('S')); echo "<script>window.open('https://rickard.co/weenclub/output_merged.pdf', '_blank');</script>"; echo "<p>✅ PDF saved. <a href='https://rickard.co/weenclub/output_merged.pdf' target='_blank'>Open PDF manually</a> if new tab didn’t launch.</p>"; exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Upload & Convert A4 Labels to A6</title> </head> <body style="font-family:sans-serif; padding:2rem;"> <h2>Upload A4 Label PDFs (Crop to A6 with Placement Control)</h2> <form method="post" enctype="multipart/form-data"> <label>Select PDFs:</label><br><br> <input type="file" name="pdfs[]" multiple accept=".pdf" required><br><br> <button type="submit">Upload & Open</button> </form> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0.4 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�