Welcome, Guest
Username: Password: Remember me

TOPIC:

Re: [solved] Creating a PDF with Cook 06 Aug 2012 11:43 #3031

  • LJ01
  • LJ01's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 78
  • Thank you received: 2
i solved my problem with this code in my pdf file
class PDF extends FPDF {
	private $surface='';
	private $data='';

	//initialise les variables globales
	function InitVar($item) {
		$this->surface 	= trim ($item->surface); 
		$this->data = JRequest::get('post');
	}
with <input in view>

and this in my controller
function printy()
	{          
		// Get data from the model
		$model = $this->getModel(batenergieitem);
		$model->activeAll();
		$model->active('predefined', 'default');
		$item		= $model->getItem();
    
           		require(JPATH_COMPONENT.'/print/pdf_file.php'); }
          
		$pdf->Output();
	}
Ce sont les fils qui font les cordes
ingall-niger.org

Please Log in or Create an account to join the conversation.

Last edit: by LJ01.

Re: [solved] Creating a PDF with Cook 06 Aug 2012 12:15 #3033

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
No.

This is wrong. It works only if the user just finished his form.
$this->data = JRequest::get('post');


REPLACE :
require(JPATH_COMPONENT.'/print/pdf_file.php');

BY :
require(JPATH_COMPONENT.'/print/pdf_file.php'); //same
//Then :
$pdf->InitVar($item);	//Here you send your item to the class (below, to code to change in your PDF class)
$pdf->Output();

PDF Class :
class PDF extends FPDF {
	private $surface='';
	private $data='';


//When is called this function ? (At the contruct, or before Output() ?? VERY IMPORTANT)

	//initialise les variables globales
	function InitVar($item) {
		$this->data = $item;
		$this->surface 	= trim ($this->data->surface); 
	}
Coding is now a piece of cake
The following user(s) said Thank You: edwardcox

Please Log in or Create an account to join the conversation.

Time to create page: 0.154 seconds

Hi All just wanted to add one more "thank you" voice to all those who discovered the value of this amazing application. The website I was working on went to production few days ago and I do not want to even try to imagine what would it take to build it without j-cook. So - endless thanks keep it running and evolving I believe it deserves to be the core tool for any joomla application! Thanks!
Michael (bmk028 - Forum)  

Get Started