Witam.
Generuje dokumenty pdf ale nie udaję mi się uzyskać efektu ich pobierania (dokument wyświetla się w przeglądarce). Chcę aby po wygenerowaniu dokumentu pokazało się okienko z możliwością jego zapisu. Co robię nie tak? Z góry dziękuję za pomoc (IMG:
style_emoticons/default/smile.gif)
Oto kod:
<?php
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=test.pdf"); header("Content-Transfer-Encoding: binary");
require_once('/libs/tcpdf/config/lang/pol.php');
require_once('/libs/tcpdf/tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Fundacja Droga');
$pdf->SetTitle('Dowód wpłaty - KP');
$pdf->SetSubject('Dowód wpłaty - KP');
$pdf->SetKeywords('Dowód wpłaty - KP, Fundacja Droga');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, 20, 'FUNDACJA DROGA', 'Dokument typu - KP'.PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN
, '', PDF_FONT_SIZE_MAIN
)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA
, '', PDF_FONT_SIZE_DATA
));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('dejavusans', '', 14, '', true);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
// Set some content to print
$html = <<<EOD
<br />
<h1 style="text-align: center;">DOWÓD WPŁATY - KP</h1>
<p style="text-align: center;">Nr. KP/01/01/2011</p><br /><br />
<table cellpadding="7">
<tr>
<td style="width: 80%; height: 50px; border: 1px solid black;">
<h2 style="margin-top: 10px; font-size: 28px;">OD KOGO:</h2><br />
<p style="font-size: 28px;">Mistrz (1980 ? Moskwa) i wicemistrz<br></p>
</td>
</tr>
<tr>
<td style="border: 1px solid black; width: 80%;">
<h2 style="font-size: 28px;">WYSZCZEGÓLNIENIE:</h2><br />
<p style="font-size: 28px; text-align: justify">Mistrz (1980 ? Moskwa) i wicemistrz (1976 ? Montreal) olimpijski, zdobywca czwartego miejsca na Igrzyskach w Monachium 1972 w biegu na 3000 m z przeszkodami, dwukrotny mistrz Europy (1974 ? Rzym i 1978 ? Praga) na tym dystansie. 10-krotny mistrz Polski; 23 razy reprezentował Polskę w meczach międzynarodowych. 10 sierpnia 1972 wyrównał rekord Europy podczas mityngu w Warszawie na dystansie 3000 m z przeszkodami 8:22,2 s. Był również wicemistrzem świata w biegach przełajowych. Do dziś posiada rekordy Polski na dystansach: 3000 m, 5000 m, 1 milę, 2 mile oraz 3000 m z przeszkodami.</p>
</td>
<td style="border: 1px solid black; width: 20%; height: 100px;">
<h2 style="font-size: 28px;">KWOTA:</h2><br />
<p style=" color: red; font-weight: bolder; font-size: 40px; text-align: justify">1 000 zł</p>
</td>
</tr>
</table>
<div style="width: 100%;"></div>
<div style="width: 100%;"></div>
<h2 style="font-size: 28px;">SŁOWNIE ZŁOTYCH: <span style="float: right; font-weight: normal;">.............................................................................
.................................................................................
.....</span></h2><br /><br />
<div style="width: 100%;"></div><br />
<p style="font-size: 28px; text-align: center;">POWYŻSZĄ KWOTĘ OTRZYMAŁEM<br />DATA I PODPIS KASJERA:</p><br />
<div style="width: 100%;"></div>
<p style="font-size: 28px; text-align: center;">...................................................................</p><br />
<div style="width: 100%;"></div>
<div style="width: 100%;"></div>
<p style="font-size: 28px;">WYSTAWIŁ: ................................................................................
..........</p>
<p style="font-size: 28px;">SPRAWDZIŁ: ................................................................................
........</p>
EOD;
// Print text using writeHTMLCell()
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
// ---------------------------------------------------------
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output("pliczek.pdf");
?>
Ten post edytował bagsiur 4.06.2011, 22:40:40