0
我嘗試呈現視圖HTML,div,tables,thead,tboody,tfoot,h2,h3和ccs。DomPdf出現錯誤在PHP中呈現html
的結果我呈現在PHP與donpdf是:
"%PDF-1.3 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R >> >> /MediaBox [0.000 0.000 612.000 792.000] >> endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj << /Creator (DOMPDF) /CreationDate (D:20130227215320+00'00') /ModDate (D:20130227215320+00'00') >> endobj 6 0 obj << /Type /Page /Parent 3 0 R /Contents 7 0 R >> endobj 7 0 obj << /Filter /FlateDecode /Length 66 >> stream x��2�[email protected]&�ҹ�B�M��́����BH����������BH��B���H�f�B���k�� endstream endobj 8 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Times-Roman /Encoding /WinAnsiEncoding >> endobj xref 0 9 0000000000 65535 f 0000000008 00000 n 0000000073 00000 n 0000000119 00000 n 0000000273 00000 n 0000000302 00000 n 0000000416 00000 n 0000000479 00000 n 0000000616 00000 n trailer << /Size 9 /Root 1 0 R /Info 5 0 R >> startxref 725 %%EOF"
任何想法,爲什麼dompdf
呈現對此有何反應?
這是代碼生成PDF:
class PdfView extends PhpView {
public $orientation = "portrait";
public $size = "letter";
function render(Response $response) {
$response->resetBuffer();
parent::render($response);
$buffer = utf8_decode($response->getBuffer());
$response->resetBuffer();
Context::load("app/core/lib/dompdf/dompdf_config.inc");
$pdf = new DOMPDF();
$pdf->set_paper($this->size,$this->orientation);
$pdf->load_html($buffer);
$pdf->render();
$render = $pdf->output();
if ($path = @$response->result->options->save)
file_put_contents($path, $render);
else {
$response->setHeader("Content-Type", "application/pdf");
echo $render;
}
}
}
應用的頭是 「應用/ PDF」。 Plz幫助我!
看起來像PDF。你是否發送了正確的內容類型頭文件? – 2013-02-27 22:01:18
@Pekka웃是對的,這幾乎是一個PDF文檔。你能發佈你使用的代碼嗎?僅供參考,'$ dompdf-> stream()'會爲您設置適當的標題。 – BrianS 2013-02-28 00:39:31