shihab mm
shihab mm

Reputation: 525

pdf creation shows an error "failed to load pdf document" in zend

i had tried to create a pdf using fpdf,dompdf and zend_pdf but always its showing an error "Failed to load pdf document". i searched for a solution in most of sites my steps are same to their steps. my code is given below.

    FPDF
    ---------
    require_once('fpdf/fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial', 'B', 16);
    $pdf->Cell(40, 10, 'Hello World!');
    $pdf->Output("dom.pdf");

    DOM PDF
    ---------
    require_once('dompdf/dompdf_config.inc.php');           
    $dompdf = new DOMPDF();
    $outfile = 'invoice.pdf';
    $dompdf = new DOMPDF();
    $dompdf->load_html("<h1>shihab</h1>");
    $dompdf->render();
    $dompdf->stream($outfile);

    ZEND_PDF
    -----------
    $pdf = new Zend_Pdf();
    $pdf->pages[0] = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
    $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
    $pdf->pages[0]->setFont($font, 16);
    $pdf->pages[0]->drawText("Shihab", 10, 800, 'UTF-8');
    $pdf->save("dom.pdf");

Please Help

Upvotes: 0

Views: 1942

Answers (1)

shihab mm
shihab mm

Reputation: 525

Hai guys finally i found the reason my self. the problem were my page completely not converting to content-type application/pdf.actually its happened in my project when i used layout page in every action. i had fixed this issue by disabling my layout in my pdf creation action just using following code

Zend_Layout::getMvcInstance()->disableLayout();

Upvotes: 1

Related Questions