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.053 seconds

Amazing Tool !
And only tool I know that allows complete Scaffolding in terms of component creation. It really saves loads of time (actually much more than that). Simple architecture enables quick and painless changes at any time. Code is clean and consintent. It's just... what's the word... neat! :) Great work! You should definetely try this one!

pi_wo (JED)
         

Get Started