How to center the header image (TCPDF)

I have the code below and I guess what is the center of the page. How could I direct the image correctly?

class MYPDF extends TCPDF {

        //Page header
        public function Header() {
                // Logo
                $image_file = K_PATH_IMAGES.'logo.png';
                $this->Image($image_file, 90, 5, 40, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);

                $style = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(39, 137, 199));

                $this->Line($this->getPageWidth()-PDF_MARGIN_RIGHT, 25, PDF_MARGIN_LEFT, 25, $style);


        }
}

thank

+4
source share
4 answers

This should work:

// Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false)

$this->Image($image_file, 'C', 6, '', '', 'JPG', false, 'C', false, 300, 'C', false, false, 0, false, false, false);

You can find more information in the API: http://www.tcpdf.org/doc/code/classTCPDF.html#a714c2bee7d6b39d4d6d304540c761352

+8
source

You have an option $palignin Image()

(line) Allows you to center or align the image on the current line. Possible values:

  • L: left alignment
  • C: center
  • R: right alignment
  • empty line: left for LTR or right for RTL

With your image:

$this->Image($image_file, 90, 5, 40, '', 'PNG', '', 'T', false, 300, 'C', false, false, 0, false, false, false);
+5
source

TCPDF HTML- + , /.

0

, HTML TCPDF, , html, PDF

<?
$html = '<h2>List Of Expediton</h2>    //Title
<table border="1" cellspacing="3" cellpadding="4">
    <tr>
        <th align="left">Title</th>                //head of column name
        <th align="center">Title</th>  //head of column name
        <th align="right">Title</th>       //head of column name
    </tr>
    <tr>
        <td>Exemple</td>
        <td>Exemple</td>
        <td>Exemple</td>
    </tr>

</table>


$pdf->writeHTML($html, true, false, true, false, ''); //function for convert to HTML
?>
0

All Articles