PHP/HTML을 사용하여 PDF를 생성하기 위해 TCPDF 라이브러리를 사용하고 있습니다. 문서는 http://www.tcpdf.org/doc/code/classTCPDF.html에서 찾을 수 있습니다.TCPDF 목차 및 페이지 번호 관련 문제
I합니다 (TCPDF 사이트에 example 59에서 입증 된 바와 같이) 목차를 만들려고하고 있어요하지만 몇 가지 문제가 발생하고있어 :
이1) 목차 페이지 번호의 표는 마지막 페이지로 표시됩니다 문서의 (실제로 8시 8 분의 2, 커버 페이지 다음에 오는 8시 8 분).
2) 다른 페이지의 페이지 번호가 조정되지 않았습니다. TOC 다음 페이지는 3/8이어야하지만 대신 2/2라고합니다.
3) 목차에 책갈피에 대한 올바른 페이지 번호가 있지만이 숫자는 해당 페이지의 페이지 번호와 일치하지 않습니다 (문제 # 2와 관련 있음).
어떻게 발생하고있어 북마크 :
나는 추가 된 각 페이지 후 북마크() 메서드를 호출하여 각 페이지에 책갈피를 생성하고있다. 나는 내용의 테이블을 생성하고있어 어떻게
$pdf->AddPage();
$pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128));
은 :
이 위에 링크 된 예 59에서 직접 찢어된다. 이 예에서 시나리오는 커버 페이지가 없기 때문에 약간 다릅니다.
// add a new page for TOC
$pdf->addTOCPage();
// write the TOC title and/or other elements on the TOC page
$pdf->SetFont('times', 'B', 16);
$pdf->MultiCell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0);
$pdf->Ln();
$pdf->SetFont('helvetica', '', 10);
// define styles for various bookmark levels
$bookmark_templates = array();
/*
* The key of the $bookmark_templates array represent the bookmark level (from 0 to n).
* The following templates will be replaced with proper content:
* #TOC_DESCRIPTION# this will be replaced with the bookmark description;
* #TOC_PAGE_NUMBER# this will be replaced with page number.
*
* NOTES:
* If you want to align the page number on the right you have to use a monospaced font like courier, otherwise you can left align using any font type.
* The following is just an example, you can get various styles by combining various HTML elements.
*/
// A monospaced font for the page number is mandatory to get the right alignment
$bookmark_templates[0] = '<table border="0" cellpadding="0" cellspacing="0" style="background-color:#EEFAFF"><tr><td width="155mm"><span style="font-family:times;font-weight:bold;font-size:12pt;color:black;">#TOC_DESCRIPTION#</span></td> <td width="25mm"><span style="font-family:courier;font-weight:bold;font-size:12pt;color:black;" align="right"> #TOC_PAGE_NUMBER#</span></td></tr></table>';
$bookmark_templates[1] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td width="5mm"> </td><td width=" 150mm"><span style="font-family:times;font-size:11pt;color:green;">#TOC_DESCRIPTION#</span></td><td width="25mm"><span style="font-family:courier;font-weight:bold;font-size:11pt;color:green;" align="right">#TOC_PAGE_NUMBER#</span></td></tr ></table>';
$bookmark_templates[2] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td width="10mm"> </td><td width=" 145mm"><span style="font-family:times;font-size:10pt;color:#666666;"><i>#TOC_DESCRIPTION#</i></span></td><td width="25mm "><span style="font-family:courier;font-weight:bold;font-size:10pt;color:#666666;" align="right">#TOC_PAGE_NUMBER#</span ></td></tr></table>';
// add other bookmark level templates here ...
// add table of content at page 1
// (check the example n. 45 for a text-only TOC
$pdf->addHTMLTOC(2, 'INDEX', $bookmark_templates, true, 'B', array(128,0,0));
// end of TOC page
$pdf->endTOCPage();
어떻게 바닥 글의 페이지 번호를 받고 있어요 :
// Page footer
public function Footer() {
$pageN = $this->PageNo();
if($pageN === 1){
// Do nothing
} else {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont($helvetica_light, '', 10);
$this->setTextColor(255,255,255);
// Page number
$this->Cell(0, 12, ' '.$this->PageNo().' of '.$this->getNumPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
기본적으로
, 나는 2 페이지 떨어 목차를하고 싶습니다, 바닥 글과 함께 페이지 2는 모든 후속 페이지 번호가 올바르게 레이블링됩니다. 어떻게해야합니까? 필요한 경우 질문/코드를 명확히 할 수 있습니다.
어떤 도움에 감사드립니다 :)
그래서 목차에 정확한 페이지 번호가 표시되지만 페이지 하단의 페이지 번호가 정확하지 않습니까? 따라서 목차 생성시 아무 것도 잘못되어 있지 않으므로 표시 할 페이지 번호가 생성되는 코드 부분을 제공 할 수 있습니까? – olger
@olger 답장을 보내 주셔서 감사합니다. 내 편집을 참조하십시오. – Andrew