Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The error <em>"Some data has already been output, can't send PDF file"</em> appears because Magento has already sent the header output. Look at <a href="http://php.net/manual/en/function.header.php" rel="nofollow noreferrer">http://php.net/manual/en/function.header.php</a> for further informations.</p> <p>So the Output() function of FPDF is also sending header informations and it declares the 'Content-Type' to 'application/pdf'. The main problem here is that you cannot just put a PDF file between HTML tags. PDF is an own format and needs a diffrent presantation mechanism than HTML. Like in the example link you gave the PDF file is embeded by the embed-tag with the right Content-Type declaration:</p> <pre><code>&lt;embed width="100%" height="100%" name="plugin" src="http://milton.bommelme.com/fpdf/pddf.php" type="application/pdf"&gt; </code></pre> <p>There are also other ways to embed a PDF file in HTML: <a href="https://stackoverflow.com/questions/291813/recommended-way-to-embed-pdf-in-html">Recommended way to embed PDF in HTML?</a></p> <p>EDIT: For example you can create two view actions. The first one renders the HTML. Inside the HTML the embed-tag calls the second action which will generate the PDF. I don't think this is the best solution,but it should work easily:</p> <pre><code>class Foo_Pdf_Controller_SomeController extends Mage_Core_Controller_Front_Action { public function viewAction() { // View stuff } public function getPdfAction() { // create pdf $fpdf-&gt;output(); } } </code></pre> <p>The embed-tags calls the getPdf() action:</p> <pre><code>&lt;embed width="100%" height="100%" name="plugin" src="url_to_getPdf_action" type="application/pdf"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload