Anonymous
Рендеринг стилей шрифта в TCPDF
Сообщение
Anonymous » 23 сен 2025, 09:35
Я не могу отобрать стили шрифтов (жирный, курсив) в PDF, сгенерированном с PHP и TCPDF.
Мой код до сих пор: < /p>
Код: Выделить всё
$pageLayout = array( 75, 50 );
$pdf = new TCPDF( "L", "mm", $pageLayout, true, 'UTF-8', false );
$pdf->SetAutoPageBreak( false );
$pdf->SetCreator( PDF_CREATOR );
$pdf->SetAuthor( 'Me' );
$pdf->SetTitle( 'Tessera ' . $_GET["anno"] . ' di ' . html_entity_decode($s->nome) . ' ' . html_entity_decode($s->cognome) );
$pdf->setImageScale( PDF_IMAGE_SCALE_RATIO );
$pdf->SetDefaultMonospacedFont( PDF_FONT_MONOSPACED );
$pdf->SetMargins( 3, 3, 3 );
$pdf->setFontSubsetting( true );
$pdf->setFont( "ubuntu", '', 11, '', true );
$pdf->setPrintHeader( false );
$pdf->setPrintFooter( false );
$html = "";
$html .= "Circolo Nautico del Finale - A.S.D.";
$html .= "";
$html .= "# Tessera ";
$html .= "" . $s->tessera_cndf . "";
$html .= "";
$html .= "[b]" . $s->nome . " " . $s->cognome . "[/b]";
$html .= "Tipo Socio: [b]" . $tipo . "[/b]";
$html .= "Data rilascio: [b]" . $dataRinnovo->format( "d/m/Y" ) . "[/b]";
$html .= "Data scadenza: [b]31/12/" . $_GET[ "anno" ] . "[/b]";
$html .= "";
$html .= " ";
$html .= "Il Presidente
[img]\[/img]
";
$html .= "";
$html .= "";
$pdf->addPage();
$w = 67;
$h = 42;
$x = 4;
$y = 4;
$pdf->writeHTMLCell( $w, $h, $x, $y, $html, $border = 0, $ln = 0, $fill = 0, $reseth = true, $align = '', $autopadding = true );
header( 'Content-Disposition: inline;filename="Tessera ' . $s->tessera_cndf . '-' . $_GET["anno"] . '.pdf"' );
ob_end_clean();
$pdf->Output( "Tessera " . $s->tessera_cndf . "-" . $_GET["anno"] . ".pdf", "I" );
На данный момент PDF отображает таблицу, даже границы и изображение, но все шрифты нормаль>
Подробнее здесь:
https://stackoverflow.com/questions/797 ... s-in-tcpdf
1758609330
Anonymous
Я не могу отобрать стили шрифтов (жирный, курсив) в PDF, сгенерированном с PHP и TCPDF. Мой код до сих пор: < /p> [code] $pageLayout = array( 75, 50 ); $pdf = new TCPDF( "L", "mm", $pageLayout, true, 'UTF-8', false ); $pdf->SetAutoPageBreak( false ); $pdf->SetCreator( PDF_CREATOR ); $pdf->SetAuthor( 'Me' ); $pdf->SetTitle( 'Tessera ' . $_GET["anno"] . ' di ' . html_entity_decode($s->nome) . ' ' . html_entity_decode($s->cognome) ); $pdf->setImageScale( PDF_IMAGE_SCALE_RATIO ); $pdf->SetDefaultMonospacedFont( PDF_FONT_MONOSPACED ); $pdf->SetMargins( 3, 3, 3 ); $pdf->setFontSubsetting( true ); $pdf->setFont( "ubuntu", '', 11, '', true ); $pdf->setPrintHeader( false ); $pdf->setPrintFooter( false ); $html = ""; $html .= "Circolo Nautico del Finale - A.S.D."; $html .= ""; $html .= "# Tessera "; $html .= "" . $s->tessera_cndf . ""; $html .= ""; $html .= "[b]" . $s->nome . " " . $s->cognome . "[/b]"; $html .= "Tipo Socio: [b]" . $tipo . "[/b]"; $html .= "Data rilascio: [b]" . $dataRinnovo->format( "d/m/Y" ) . "[/b]"; $html .= "Data scadenza: [b]31/12/" . $_GET[ "anno" ] . "[/b]"; $html .= ""; $html .= " "; $html .= "Il Presidente [img]\[/img] "; $html .= ""; $html .= ""; $pdf->addPage(); $w = 67; $h = 42; $x = 4; $y = 4; $pdf->writeHTMLCell( $w, $h, $x, $y, $html, $border = 0, $ln = 0, $fill = 0, $reseth = true, $align = '', $autopadding = true ); header( 'Content-Disposition: inline;filename="Tessera ' . $s->tessera_cndf . '-' . $_GET["anno"] . '.pdf"' ); ob_end_clean(); $pdf->Output( "Tessera " . $s->tessera_cndf . "-" . $_GET["anno"] . ".pdf", "I" ); [/code] На данный момент PDF отображает таблицу, даже границы и изображение, но все шрифты нормаль> Подробнее здесь: [url]https://stackoverflow.com/questions/79770979/render-font-styles-in-tcpdf[/url]