fix(pdf-download): avoid empty abstract in PDF output

Added conditional check to ensure the abstract is only included in the PDF if it exists. This prevents empty or malformed sections when post excerpts are not provided, improving the readability and quality of the generated PDF documents.
This commit is contained in:
Kumi 2024-08-07 16:12:18 +02:00
parent 4de71503e8
commit 5522a4599e
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -885,10 +885,12 @@ function handle_pdf_download()
}
// Set abstract
$pdf->Ln(10);
$pdf->SetFont('helvetica', '', 12);
$pdf->setTextColor(128);
$pdf->writeHTML("<b>Abstract:</b> " . $post->post_excerpt);
if ($post->post_excerpt) {
$pdf->Ln(10);
$pdf->SetFont('helvetica', '', 12);
$pdf->setTextColor(128);
$pdf->writeHTML("<b>Abstract:</b> " . $post->post_excerpt);
}
// Set content
$pdf->setTextColor(0);