@php $paperSizes = ['A4' => [210, 297], 'Letter' => [216, 279], 'Legal' => [216, 356], 'A5' => [148, 210]]; $isPromiseDocument = str_contains((string) $contract->body, 'promesa-page') || str_contains(mb_strtolower((string) $contract->title), 'promesa'); $effectivePageSize = $isPromiseDocument ? 'Legal' : ($contract->page_size ?? 'A4'); [$basePageWidth, $basePageHeight] = $paperSizes[$effectivePageSize] ?? $paperSizes['A4']; $pageOrientation = ($contract->orientation ?? 'portrait') === 'landscape' ? 'landscape' : 'portrait'; [$pageWidth, $pageHeight] = $pageOrientation === 'landscape' ? [$basePageHeight, $basePageWidth] : [$basePageWidth, $basePageHeight]; $pageFont = in_array($contract->default_font, ['Arial', 'Calibri', 'Georgia', 'Times New Roman', 'Verdana'], true) ? $contract->default_font : 'Georgia'; $designTheme = in_array($contract->design_theme ?? 'modern', ['modern', 'classic'], true) ? ($contract->design_theme ?? 'modern') : 'modern'; @endphp