diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php
index 8b3ea23..9111716 100644
--- a/app/Controllers/Ipd_discharge.php
+++ b/app/Controllers/Ipd_discharge.php
@@ -7377,19 +7377,15 @@ class Ipd_discharge extends BaseController
$namedBlocks .= '' . "\n" . $footerHtml . "\n" . '' . "\n";
}
- $prefixHtml = $namedBlocks;
-
+ // Single WriteHTML call: mPDF does not require full HTML document structure.
$templateCss = trim((string) ($templateSettings['template_css'] ?? ''));
- $cssBlock = $templateCss !== '' ? '' : '';
- $pdfHtml = $this->buildDischargePdfHtml($panelData, $renderedHtml, $withHeader, $templateName);
- // Inject @page and template CSS into
so they apply globally.
- $pdfHtml = str_replace('', $pageBlock . $cssBlock . '', $pdfHtml);
+ $pdfHtml = $pageBlock
+ . $namedBlocks
+ . ($templateCss !== '' ? '' . "\n" : '')
+ . $renderedHtml;
$pdfHtml = mpdf_normalize_font_weight_css($pdfHtml);
- $pdfBinary = $this->runMpdfWithTolerantWarnings(static function () use ($mpdf, $prefixHtml, $pdfHtml, $fileName): string {
- if ($prefixHtml !== '') {
- $mpdf->WriteHTML($prefixHtml, \Mpdf\HTMLParserMode::HTML_HEADER_BUFFER);
- }
+ $pdfBinary = $this->runMpdfWithTolerantWarnings(static function () use ($mpdf, $pdfHtml, $fileName): string {
$mpdf->WriteHTML($pdfHtml);
return $mpdf->Output($fileName, Destination::STRING_RETURN);
@@ -7904,22 +7900,15 @@ class Ipd_discharge extends BaseController
private function buildDischargePdfHtml(array $panelData, string $renderedContent, bool $withHeader, string $templateName): string
{
- // Keep PDF body clean; header/footer is handled via mPDF SetHTMLHeader/SetHTMLFooter.
-
- return ''
- . ''
- . ''
- . '' . $renderedContent . '
'
- . '';
+ . 'table{width:100%;border-collapse:collapse;margin:6px 0 10px 0;font-size:10pt;}'
+ . 'th,td{border:1px solid #d1d5db;padding:5px;vertical-align:top;}'
+ . 'table.no-border th,table.no-border td,table[border="0"] th,table[border="0"] td{border:none !important;}'
+ . 'ul,ol{margin:4px 0 10px 18px;padding:0;}'
+ . ''
+ . $renderedContent;
}
private function cacheAbdmIpdPdf(int $ipdId, string $fileName, string $pdfBinary): void