php - Failed to Load Pdf Document with TCPDF -


now i'm working on convert html file pdf in zend framework, i'm using tcpdf doing this, following code.

$pdf = new tcpdf(pdf_page_orientation, pdf_unit, pdf_page_format, true,    'utf-8', false); $view = new zend_view(); $htmlcontent = $view->render('media-file.phtml'); $pdf->addpage();  $pdf->writehtml($htmlcontent, true, 0, true, 0); $pdf->lastpage(); $pdf->output("single-page.pdf", 'd'); 

my problem file downloading, when opened downloaded file shows 'failed load pdf document'. don't know i'm wrong. please let me know

there many places problems might occurring.

firstly, html valid? tcpdf expects valid html, handles subset of html , html attributes must enclosed in double-quotes, should check things before going further.

http://www.tcpdf.org/doc/code/classtcpdf.html#ac3fdf25fcd36f1dce04f92187c621407

next 'failed load pdf document' error. application showing error? problem file wasn't downloaded browser, or pdf reader couldn't open it?

instead of sending pdf file browser, try saving file. way eliminate issues might happening browser (and issues might happening stray data being sent browser before download).

once writing pdf directly file, @monkeyzeus said, try opening in notepad or using "head" command if have available @ first few lines. if doesn't start pdf not valid:

%pdf-1.7 

if still can't solve problem, helpful post link sample of html , know version of tcpdf using. setting php error level high @monkeyzeus suggested , including error messages helpful.


Comments