tags:

views:

594

answers:

1

Hi,

Is there any feature to retrive some content from the Cakephp controller side and to send it to a File which then opens a Print dialog box to send it to a Printer in Cakephp or JQuery..

Thanks in Advance...

A: 

Firstly, you might want to consider using a print stylesheet. This will allow you to hide certain things from your layout when users print your pages such as the navigation, the search box, the footer, etc.

Secondly, you can use jQuery to unobtrusively insert a javascript "Print this page" link which will popup the browser's "Print" dialog on the user's screen when activated.

Since this is a client side thing, there is no real CakePHP solution for the problem. The only thing you can do is disable or change the layout used with the following in your controller:

  • $this->layout = false;
  • $this->layout = 'print';
deizel
You don't actually need jquery or any framework to call the print dialog.
Adriano Varoli Piazza
In this answer I had linked to jQuery examples since it appears from previous questions by Aruna that the application in question uses jQuery extensively. It is however worth noting that this can be done simply with Javascript and jQuery isn't providing the print dialog functionality as my answer doesn't point out. Thanks.
deizel