SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->setCellHeightRatio(1.5);
$pdf->SetMargins(25, 27, 25);
$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM - 5);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('dejavusans', '', 10);
$pdf->setHtmlVSpace([
'ul' => [['h' => 0, 'n' => 0], ['h' => 0, 'n' => 0]],
'li' => [['h' => 0, 'n' => 0], ['h' => 0, 'n' => 0]],
'ol' => [['h' => 0, 'n' => 0], ['h' => 0, 'n' => 0]],
'div' => [['h' => 0, 'n' => 0], ['h' => 0, 'n' => 0]],
'p' => [['h' => 0, 'n' => 0], ['h' => 0, 'n' => 0]],
'blockquote' => [['h' => 0, 'n' => 0], ['h' => 0, 'n' => 0]],
]);
$this->pdf = $pdf;
return $pdf;
}
public static function printHeaderTable(\TCPDF $pdf, ?string $pdfIntroduction, string $tableContent): void
{
$title = str_replace("\n", '
', $pdfIntroduction);
$pdf->SetY(35);
if ($title) {
$pdf->SetFont("helvetica", "", 13);
$pdf->writeHTMLCell(185, 0, 10, 10, $title, 0, 1, false, true, 'R');
}
$pdf->SetFont("helvetica", "", 12);
$pdf->setCellPaddings(2, 4, 2, 4);
$pdf->writeHTMLCell(170, 0, 25, 35, $tableContent, 1, 1, false, true, 'L');
$pdf->Ln(7);
$pdf->setCellPaddings(0, 0, 0, 0);
}
public function printMotionHeader(Motion $motion): void
{
/** @var BDKPDF $pdf */
$pdf = $this->pdf;
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->startPageGroup();
$pdf->AddPage();
$pdf->setDestination('motion' . $motion->id, 0, '');
$pdf->Bookmark($motion->getTitleWithPrefix(), 0, 0, '', 'BI', [128,0,0], -1, '#motion' . $motion->id);
$pdf->setMotionTitle($motion->getFormattedTitlePrefix() ?? '', $motion->title);
$pdf->setPrintHeader(true);
$pdf->setPrintFooter(true);
$title = $motion->getMyMotionType()->getSettingsObj()->pdfIntroduction;
if ($title === \Yii::t('export', 'Initiators')) { // The default setting is just a placeholder
$title = '';
}
$motionData = '';
$motionData .= Html::encode($motion->getFormattedTitlePrefix() ?? '') . ' ';
$motionData .= '';
$motionData .= Html::encode($motion->title) . '';
$motionData .= '
';
$motionData .= '
';
foreach ($motion->getDataTable() as $key => $val) {
$motionData .= '| ' . Html::encode($key) . ': | ';
$motionData .= '' . Html::encode($val) . ' |
';
}
$motionData .= '
';
BDK::printHeaderTable($this->pdf, $title, $motionData);
}
public function printAmendmentHeader(Amendment $amendment): void
{
/** @var BDKPDF $pdf */
$pdf = $this->pdf;
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->startPageGroup();
$pdf->AddPage();
$pdf->setDestination('amendment' . $amendment->id, 0, '');
$pdf->Bookmark($amendment->getTitleWithPrefix(), 0, 0, '', 'BI', [128,0,0], -1, '#amendment' . $amendment->id);
$pdf->setMotionTitle($amendment->getFormattedTitlePrefix() ?? '', '');
$pdf->setPrintHeader(true);
$pdf->setPrintFooter(true);
$title = $amendment->getMyMotionType()->getSettingsObj()->pdfIntroduction;
$amendmentData = '';
$amendmentData .= Html::encode($amendment->getTitle()) . '';
$amendmentData .= '
';
$amendmentData .= '';
$amendmentData .= '| ' . Html::encode(\Yii::t('motion', 'initiators_head')) . ' | ';
$amendmentData .= '' . Html::encode($amendment->getInitiatorsStr()) . ' |
';
$amendmentData .= '
';
BDK::printHeaderTable($this->pdf, $title, $amendmentData);
}
}