2014-02-28 6 views
1

에 당신이 셀이 올바르게 배치지고 이미지에서 볼 수 있듯이 바닥 글 텍스트를TCPDF 센터 텍스트가 완전히 센터

function Footer(){ 
    $txt = 'Page %s of %s'; 
    if (empty($this->pagegroups)) { 
     $txt = sprintf($txt, $this->getAliasNumPage(), $this->getAliasNbPages()); 
    } else { 
     $txt = sprintf($txt, $this->getPageNumGroupAlias(), $this->getPageGroupAlias()); 
    } 
    $this->MultiCell(0, 0, $txt, 1, 'C', false, 1, PDF_MARGIN_LEFT, $this->y); 
} 

의 중심을하려고하지, 문제는 텍스트를 중심으로한다.

$this->SetXY(PDF_MARGIN_LEFT, $this->y); 
$this->Cell(0, 0, $txt, 1, 1, 'C'); 
+0

중복 : http://stackoverflow.com/questions/5485295/tcpdf-pagenumbers-not-exactly-right-aligned – user2345998

답변

1

은 어떻게 든 getAliasNumPage()getPageNumGroupAlias() 오른쪽에 공백의 무리를 추가 : 좀 더 똑바로 앞으로 뭔가에 멀티 셀을 변경하는 경우

enter image description here

나는 같은 결과를 얻을. 나는 왜 그런지 확신 할 수 없다. 하지만 그 대신 PageNo()getGroupPageNo()을 사용하면 문제가 해결된다는 것을 알고 있습니다.

public function Footer() { 

    $this->SetY(-15); //not present in your code but was necessary for me to have the footer be positioned correctly 

    $txt = 'Page %s of %s'; 
     if (empty($this->pagegroups)) { 
      $txt = sprintf($txt, $this->PageNo(), $this->getAliasNbPages()); 
     } else { 
      $txt = sprintf($txt, $this->getGroupPageNo(), $this->getPageGroupAlias()); 
     } 
     $this->MultiCell(0, 0, $txt, 1, 'C', false, 1); 
     } 
    } 
+0

getAliasNumPage() 반환

은 나를 위해 일한 코드입니다 alis는 "실제"페이지 번호로 대체됩니다. 이 별칭은 "{: ptp :}"이며 가운데 맞춤 계산에서 실제 페이지 번호 대신이 값을 사용하는 것처럼 보입니다. 이것이 버그라고 생각합니다 ... – user2345998