1

I am trying to convert a dynamically generated page using html2pdf and I get this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/renal_prescRequest_review.php:78) in /home/test/html2pdf/_tcpdf_5.0.002/tcpdf.php on line 6141

TCPDF ERROR: Some data has already been output to browser, can't send PDF file...

I do not fully understand the reason for this error.

Actually I would like my program to download the contents of the page as PDF.

Community
  • 1
  • 1
Damilare Binutu
  • 161
  • 2
  • 2
  • 14

1 Answers1

0

The "link" to your generated pdf need to point to an target="_blank" , if this open a new page and in this new page will open the pdf, then problem solved.

Goikiu
  • 574
  • 3
  • 12
  • Here's the code that generates my PDF writeHTML($content, isset($_GET['vuehtml'])); $html2pdf->Output('exemple01.pdf'); } catch(HTML2PDF_exception $e) { echo $e; exit; Now I get error on PDF that says: include(renal_prescRequest_review.php?id=) failed to open stream: No such file or directory } ?> – Damilare Binutu Dec 27 '13 at 16:23
  • This page is dynamically generated, and I need to send id with it. Please is there something I'm doing wrongly? Thanks – Damilare Binutu Dec 27 '13 at 16:29
  • If you want the .pdf to be shown... put it into an iframe, ONLY the pdf output ok? – Goikiu Dec 27 '13 at 16:37
  • Ok. the .pdf is shown but instead of displaying HTML page it displays Warning : include(renal_prescRequest_review.php?id=) [ function.include ]: failed to open stream: No such file or directory in /public_html/testing/test/renal_prescRequest_pdf.php on line 5. As I said earlier My HTML is dynamically generated via id returned from a database – Damilare Binutu Dec 27 '13 at 18:51
  • Ok, if you put all the code into the iframe? Will change something? – Goikiu Dec 27 '13 at 18:53
  • Assume i have file1.php which contains a link to file1_pdf.php which is the php that performs the whole conversion. I have code like this in file1_pdf.php $id = $_GET['id']; // get the HTML ob_start(); include("renal_prescRequest_review.php?id=$id"); $content = ob_get_clean(); Do you think this is valid, because the PDF is throwing Warning:include(renal_prescRequest_review.php?id=) [ function.include:failed to open stream:No such file or directory in /testing/test/renal_prescRequest_pdf.php on line 5. – Damilare Binutu Dec 27 '13 at 19:08
  • nope, i don't think it work correctly. You need to include the file without variables (like ?id=etc), but you need to "call" a function giving it parameters, this way it can work probably. – Goikiu Dec 27 '13 at 19:20
  • Could you please site an example of what you mean. I mean a technical example.. – Damilare Binutu Dec 27 '13 at 19:26
  • Something like on row 1 include_once(myPagePdf.php); and on row 2 myPdfCreator($id); on the other side i do everything from myPagePdf, having a method similar to public function myPdfCreator($givenId){ //etc } that will create and print the pdf when called. – Goikiu Dec 27 '13 at 19:32
  • I have tried to include the URL in this manner include(page.php?id=1).. It throws the same error.. Have you any idea what could be wrong at this point. Thanks for your help.\ – Damilare Binutu Dec 27 '13 at 20:43