2014-11-13 4 views
1

tcpdf에서 일부 페이지를 추가하려고하는데 Wrong page number on setPage() function: 0이 해결 방법을 찾을 수 없습니다. 내가 $pdf->getNumPages();0을 반환하지만 for 루프에서 내가 $i=1; $i<=$ttPages; $i++을 추가 한 생각tcpdf 페이지 번호가 0이 됨

require_once('../tcpdf.php'); 
// Extend the TCPDF class to create custom Header and Footer 
class MYPDF extends TCPDF { 
//Page header 
public function Test($ae) { 
    if(!isset($this->xywalter)) { 
     $this->xywalter = array(); 
    } 
    $this->xywalter[] = array($this->GetX(), $this->GetY()); 
} 
} 

// create new PDF document 
$pdf = new MYPDF('L', PDF_UNIT, 'A1', true, 'UTF-8', false); 

// set Rotate 
$params = $pdf->serializeTCPDFtagParameters(array(90)); 

// other configs 
$pdf->setOpenCell(0); 
$pdf->SetCellPadding(0); 
$pdf->setCellHeightRatio(1.25); 

// create some HTML content 
$html = '<table width="100%" border="1" cellspacing="0" cellpadding="5"> 
<thead> 
<tr bgcolor="#E6E6E6"> 
<th rowspan="2" width="15%" align="center">ATIVIDADES E PROCESSOS</th> 
<th rowspan="2" width="10%" align="center" valign="bottom">ASPECTOS</th> 
<th rowspan="2" width="10%" align="center">IMPACTOS</th> 
<th colspan="3" width="6%" align="center">MEIO</th> 
<th rowspan="2" width="3%" align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th colspan="9" width="18%" align="center">CLASSIFICA&Ccedil;&Otilde;ES</th> 
<th rowspan="2" width="3%" align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th rowspan="2" width="10%" align="center">PROGRAMA</th> 
<th rowspan="2" width="10%" align="center">SUBPROGRAMA</th> 
<th rowspan="2" width="15%" align="center">A&Ccedil;&Otilde;ES DE CONTROLE, MEDIDAS MITIGADORAS, COMPENSAT&Oacute;RIAS E POTENCIALIZADORAS</th> 
</tr> 
<tr bgcolor="#E6E6E6"> 
<th align="center" height="200"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
<th align="center"><tcpdf method="Test" params="'.$params.'" /></th> 
</tr> 
</thead> 
<tr bgcolor="#E6E6E6"> 
<td colspan="20" align="center">Planejamento</td> 
</tr> 
<tr bgcolor="#FFFFFF"> 
<td rowspan="3" width="15%" align="left" bgcolor="#FFFFFF">Divulga&ccedil;&atilde;o do empreendimento</td> 
<td rowspan="2" width="10%" align="left">Oferta de empregos diretos e indiretos</td> 
<td rowspan="2" width="10%" align="left">Atra&ccedil;&atilde;o de popula&ccedil;&atilde;o para as comunidades do entorno</td> 
<td rowspan="2" width="2%" align="center"></td> 
<td rowspan="2" width="2%" align="center"></td> 
<td rowspan="2" width="2%" align="center">X</td> 
<td rowspan="2" width="3%" align="center">AII</td> 
<td rowspan="2" width="2%" align="center">-</td> 
<td rowspan="2" width="2%" align="center">Ind</td> 
<td rowspan="2" width="2%" align="center">T</td> 
<td rowspan="2" width="2%" align="center">Mp</td> 
<td rowspan="2" width="2%" align="center">Po</td> 
<td rowspan="2" width="2%" align="center">D</td> 
<td rowspan="2" width="2%" align="center">R</td> 
<td rowspan="2" width="2%" align="center">M</td> 
<td rowspan="2" width="2%" align="center">M</td> 
<td rowspan="2" width="3%" align="center">M</td> 
<td width="10%">Programa de Apoio ao Desenvolvimento Socioeconomico da Regi&atilde;o</td> 
<td width="10%">Subprograma de Apoio ao Desenvolvimento Habitacional</td> 
<td width="15%">Coibir ocupa&ccedil;&atilde;o indevida de &aacute;reas inadequadas</td> 
</tr> 
<tr bgcolor="#FFFFFF"> 
<td>Programa de Comunica&ccedil;&atilde;o Social</td> 
<td> -</td> 
<td>A&ccedil;&otilde;es de comunica&ccedil;&atilde;o sobre o empreendimento e quest&otilde;es ambientais</td> 
</tr> 
<tr bgcolor="#FFFFFF"> 
<td align="left">Gera&ccedil;&atilde;o de expectativas na popula&ccedil;&atilde;o</td> 
<td align="left">Gera&ccedil;&atilde;o de expectativas junto a popula&ccedil;&atilde;o</td> 
<td align="center"></td> 
<td align="center"></td> 
<td align="center">X</td> 
<td align="center">AII</td> 
<td align="center">-</td> 
<td align="center">Dir</td> 
<td align="center">T</td> 
<td align="center">Im</td> 
<td align="center">Co</td> 
<td align="center">L</td> 
<td align="center">R</td> 
<td align="center">P</td> 
<td align="center">P</td> 
<td align="center">B</td> 
<td>Programa de Comunica&ccedil;&atilde;o Social</td> 
<td> -</td> 
<td>A&ccedil;&otilde;es de comunica&ccedil;&atilde;o sobre o empreendimento e questoes ambientais</td> 
</tr> 
</table>'; 

// output the HTML content 
$pdf->writeHTML($html, true, false, true, false, ''); 

// array with names of columns 
$arr_nomes = array(
array("ABRANGÊNCIA", 8, 59), // array(name, new X, new Y); 
array("SIGNIFICÂNCIA", 8, 59), 
array("FÃSICO", 4, 52), 
array("BIÓTICO", 4, 52), 
array("SOCIOECONÔMICO", 4, 52), 
array("NATUREZA", 4, 52), 
array("ORIGEM", 4, 52), 
array("DURAÇÃO", 4, 52), 
array("OCORRÊNCIA/TEMPORALIDADE", 4, 52), 
array("FREQUÊNCIA", 4, 52), 
array("ESPACIALIZAÇÃO", 4, 52), 
array("REVERSIBILIDADE", 4, 52), 
array("MAGNITUDE", 4, 52), 
array("RELEVÂNCIA", 4, 52) 
); 

// num of pages 
$ttPages = $pdf->getNumPages(); 
for($i=1; $i<=$ttPages; $i++) { 
// set page 
$pdf->setPage($i); 
// all columns of current page 
foreach($arr_nomes as $num => $arrCols) { 
    $x = $pdf->xywalter[$num][0] + $arrCols[1]; // new X 
    $y = $pdf->xywalter[$num][1] + $arrCols[2]; // new Y 
    $n = $arrCols[0]; // column name 
    // transforme Rotate 
    $pdf->StartTransform(); 
    // Rotate 90 degrees counter-clockwise 
    $pdf->Rotate(90, $x, $y); 
    $pdf->Text($x, $y, $n); 
    // Stop Transformation 
    $pdf->StopTransform(); 
} 
} 

// reset pointer to the last page 
$pdf->lastPage(); 

// --------------------------------------------------------- 

//Close and output PDF document 
$pdf->Output('example_006.pdf', 'I'); 

:

여기 내 코드입니다. 여기 내가 가지고 오류입니다 사항은 : 오프셋 정의되지 않은 : 0 E에 : \ SOFTWARE \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,126

주의 사항 : 오프셋 정의되지 않은 : 0 E에 : \ 소프트웨어 \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,491

주의 사항 : E 0 : 오프셋 정의되지 않은 \ 소프트웨어 \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,491

Notice : 정의되지 않은 오프셋 : 0 E : \ software \ html \ own \ office \ tcpdf \ tcpdf.php 라인 17941

Notice : E : \ software \ html \ own \ office \ tc에 정의되지 않은 오프셋 : 0 온라인에서 PDF \의 tcpdf.php 18,239

사항은 : 오프셋 정의되지 않은 : 0 E에서 : \ 소프트웨어 \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 공지 17,126

: 오프셋 정의되지 않은 : 0 E에 : \ SOFTWARE \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,491

주의 사항 : E 0 : 오프셋 정의되지 않은 \ 소프트웨어 \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,491

Notice : 정의되지 않은 오프셋 : E : \ software \ html \ own \ office \ tcpdf \ tcpdf.php 라인 17941

Notice : 정의되지 않은 오프셋 : E : \ software \ html \ own \ office \ tcpdf \ tcpdf \ tcpdf의 정의되지 않은 오프셋 : 0 .PHP 라인에 17,491

사항은 : 오프셋 정의되지 않은 : 0 E에 : \ SOFTWARE \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,941

주의 사항 : E 0 : 오프셋 정의되지 \ 소프트웨어 \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 18,239

주의 사항 : E 0 : 오프셋 정의되지 않은 \ 소프트웨어 \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,491

공지 사항은 : 오프셋 정의되지 않은 : 0 E에 : \ SOFTWARE \ HTML 자신의 \ 사무실 \ \ TCPDF \ tcpdf.php 라인에 17,126

주의 사항 : E 0 : 오프셋 정의되지 \ SOFTWARE \ HTML 자신의 \ 사무소 \ \ tcpdf \ tcpdf.php on line 17491 TCPDF 오류 : setPage() 함수의 잘못된 페이지 번호 : 0 감사합니다.

답변

3

보십시오이

$pdf->AddPage('P','A4');$html