FPDF - I need to customize the text that will be printed

Asked

Viewed 422 times

1

I need the contents $pdf->MultiCell be customized(html) with bold, etc...

<?php
    require_once( 'fpdf.php' );

    $nome  = @$_POST['nome']; // Sim, a supressão é perfeitamente válida neste contexto
    $horas = @$_POST['horas']; // pois os parâmetros serão checados logo em seguida.
    $data  = @$_POST['omail'];
    $datan  = @$_POST['datan'];


    class PDF extends FPDF
    {
        // Page header
        function Header()
        {
            // Logo
            $this->Image('cabecalho.png',-20,2,250);
            // Arial bold 15
            $this->SetFont('Arial','B',15);
            // Move to the right
            $this->Cell(80);
            // Line break
            $this->Ln(20);
        }

        // Page footer
        function Footer()
        {
            // Logo
            $this->Image('rodape.png',-20,270,250);
            // Position at 1.5 cm from bottom
            $this->SetY(-15);
            // Arial italic 8
            $this->SetFont('Arial','I',8);
            // Page number
            $this->Cell(210,-17,'Página '.$this->PageNo().'/{nb}',0,0,'C');
        }
    }

    // Instanciation of inherited class
    $pdf = new PDF();
    $pdf->AliasNbPages();
    $pdf->AddPage();
    $pdf->SetFont('Times','',12);
        $pdf->SetFont('Arial','', 10);
        $pdf->SetXY( 10, 50 );
        $pdf->MultiCell( 190, 6,
          "Caro $nome

          [b]CONTRATADA</b>");

    $pdf->Output();
?>
  • I’d still prefer the isset at the @, something like if (isset($_POST['nome'], $_POST['horas'], $_POST['omail'], $_POST['datan'])) { ... executa aqui dentro .... }, with @the error log is triggered internally yet, the performance is not a great thing and still breaking without the IF can check there and cause a PDF malformed and unexpected.

  • Whenever posting this type of doubt, reduce the code to a [mcve], and explain the difficulty better, so the post is more suitable within the objectives of the site.

1 answer

0

Try this:

$pdf->SetFont('Arial','B', 10);
    $pdf->SetXY( 10, 50 );
    $pdf->MultiCell( 190, 6,
      "Caro $nome

      [b]CONTRATADA</b>");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.