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

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started