Welcome, Guest
Username: Password: Remember me

TOPIC: [solved] Creating a PDF with Cook

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

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
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
Last Edit: 06 Aug 2012 11:44 by LJ01.
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
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 administrator has disabled public write access.
The following user(s) said Thank You: edwardcox
Time to create page: 0.208 seconds

Get Started