I am trying to create a PDF using the SugarpdfSmarty class in a logic_hook.php file. My code looks as follows:

require_once('include/Sugarpdf/sugarpdf/sugarpdf.smarty.php');

class SSFGSugarpdfTest extends SugarpdfSmarty{
function preDisplay(){
parent:reDisplay();
$this->templateLocation = "modules/SSFG_INSTRUCTION_LIST/tpls/test.tpl";
$this->ss->assign("AA","HELLO");
$this->ss->assign("BB","2");
$this->ss->assign("CC","3");
$this->ss->assign("DD","4");
}
}

class SSFG_Instruction_PDF_hook extends SugarBean {

function SSFG_Instruction_PDF_hook() {
global $sugar_config;
parent::SugarBean();
}

function Save_hook(&$bean, $event, $arguments) {

$thing = new SSFGSugarpdfTest();
$thing->preDisplay();
$thing->Output('example_003.pdf', 'I');
$GLOBALS['log']->fatal($thing->displayErrors());

} // end function
} // end class

Now, this code runs as "save" hook to one of my modules.

Is this the correct way of doing this (I am not getting any errors or PDF files out of this)? I have verified that this hook triggers.
If I remove thye line: "$thing->Output('example_003.pdf', 'I');" I dont get the PDF file

If I keep that line I get the error : "TCPDF ERROR: Some data has already been output, can't send PDF file "

Thx!