witam serdecznie,
chciałam się uprzejmiej dopytać , ponieważ stoję w miejscu. korzystam z przykładu:
http://www.startutorial.com/articles/view/33
szukałam w Google, były informacje, aby poprawić na kodowanie UTF-8 i poprawiłam, ale bez rezultatu nadal biała strona . Dane są przekazane pr($teacher); wyświetlają się dane
Controller:
<?php
class PdfsController extends AppController {
var $uses = array('teacher', 'student');
var $helpers = array('Pdf');
var $name = 'Pdfs';
function index($id = null) {
$this->layout = 'pdf';
$ad = $this->student->find('all', array('students' => array('student.teacher_id' => $id), 'teachers'=> 'teacher.student_id' ));
pr($teacher);
$this->set(compact('teacher'));
}
}
?>
helpers
<?php
App::import('Vendor' , 'TCPDF' , array('file' => 'tcpdf/tcpdf.php'));
class PdfHelper extends AppHelper {
var $core;
function PdfHelper() {
$this->core = new TCPDF();
// $pdf->core->TCPDFfunction();
}
}
?>
layouts / pdf.ctp
<?php
header("Content-type: application/pdf");
echo $content_for_layout;
?>
pdfs/ index.ctp
<?php
ob_start();
foreach($students as $student) {
$html = "<table>
<tr>
<th>
..................
</th>
<th>";
$html .= $student['student']['kol0'];
$html .= "</th>
</tr></table> ";
}
$html .= "<table>
<tr>
<th>
................
</th>
<th >
..................
</th>
</tr> ";
foreach ($teachers as $teacher) {
$html.= " <tr >
<td>"; $html.= $teacher['teacher']['kol1']; $html.="</td>
<td>
2a
</td>
</tr>
<tr>
<td>"; $html.= $teacher['teacher']['kol2']; $html.="</td>
<td>
2b
</td>
</tr>
<tr>
<td>"; $html.= $teacher['teacher']['kol3']; $html.="</td>
<td>
...........
</td>
<tr >
<td>"; $html.= $teacher['teacher']['kol4']; $html.="</td>
<td>
2b
</td>
</tr>
<tr >
<td>"; $html.= $teacher['teacher']['kol5']; $html.="</td>
<td>
...........
</td>
</tr>
<tr>
<td>"; $html.= $teacher['teacher']['kol6']; $html.="</td>
<td>
2b
</td>
</tr>
<tr>
<td>"; $html.= $teacher['teacher']['kol7']; $html.="</td>
<td>
...........
</td>
</tr>
<tr>
<td>"; $html.= $teacher['teacher']['kol8']; $html.="</td>
<td>
2b
</td>
</tr>
</table>";
}
$html .= "<table >
<tr >
<th> Nazwa kolumny 1 </th>
<th> Nazwa kolumny 2 </th>
<th> Nazwa kolumny 3 </th>
<th> Nazwa kolumny 4 </th>
<th> Nazwa kolumny 5 </th>
<th> Nazwa kolumny 6 </th>
</tr>
";
foreach($students as $student) {
$html.="<tr ><td> ";
$html.= $student['student']['kol1'];
$html.="</td> <td>";
$html.= $student['student']['kol2'];
$html.="</td> <td>";
$html.= $student['student']['kol3'];
$html.="</td> <td>";
$html.= $student['student']['kol4'];
$html.="</td> <td>";
$html.= $student['student']['kol5'];
$html.="</td> <td>";
$html.= $student['student']['kol6'];
$html.="</td> </tr>";
}
$html.="</table>";
$html.="<table >
<tr>
<td> Nazwa kolumny 7 </td>
<td>"; $html.= $student["student"]["kol7"]; $html.="</td>
</tr>
<tr>
<td> Nazwa kolumny 8 </td>
<td> 11111111111111111 </td>
</tr>
</table>";
$html.="<table>
<tr>
<td>
.................................
</td>
<td>
.................................
</td>
</tr>
</table> ";
ob_end_clean();
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->AddPage();
$pdf->writeHTML($html, true, 0);
$pdf->Output('somefile.pdf', 'D');
?>
nie za bardzo wiem gdzie błąd , uprzejmiej proszę o wskazówkę Chciałabym, aby pdf się otwierał na stronie