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

This is what you call a component builder. I was able to master using this in a very short time and the resulting component works like a charm. Not just a basic component builder but a fully working component builder with forms fields tables all ready to go. You can make the list and item views to display in the front and back end. Also there is a great forum just starting to evolve and I'm sure this will grow very rapidly when you all realise how good this tool is.
Kevin (JED)

         

Get Started