我有下面的代码,并且我逐个眼睛猜测页面的中心是什么。我如何以正确的方式将图像居中?

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);


        }
}

谢谢

最佳答案

这应该工作:

// 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);

您可以在API中找到更多信息:http://www.tcpdf.org/doc/code/classTCPDF.html#a714c2bee7d6b39d4d6d304540c761352

关于php - 如何在标题中居中放置图像(TCPDF),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5885713/

10-14 19:51