Written by James McDonald

September 20, 2014

This is brilliant:- http://www.martin-schenk.es/en/cakephp-2-pdf-with-tcpdf/

in View/Layout/pdf/pdf.ctp

<?php
 
header("Content-type: application/pdf");
 
echo $content_for_layout;

But with google chrome using the $pdf->Output(‘filename.pdf’, ‘I’) option you get the raw text of the PDF to the screen in other words garbage.

However if you remove the header from the layout:

<?php 
echo $content_for_layout; 

And then add the following to your controller

 function create_pdf($id = null) {
        // logic and options here

        // this is what you need to render
        // tcpdf output to an I (inline) target for 
        // Google Chrome
        $this->response->type('application/pdf');
        // ...

    }

Following the recommendation from http://stackoverflow.com/questions/16048922/cakephp-2-x-tcpdf-output-chrome

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...