[eluser]ephlodur[/eluser]
Hello heenji and all,
Thanks a lot for your help.
I have manage to load the class with minor changes to the file provided by heenji.
The content of the "lib" directory for PHPRtfLite is located in application/libraries/PHPRtfLite
the file below "PHPRtfLite.php" is located in the directory application/libraries.
Code:
<?php
if (!defined('BASEPATH')) {exit('No direct script access allowed');}
class PHPRtfLite
{
/**
* Constructor
*
* @param string $class class name
*/
$rtf = NULL;
function __construct()
{
$dir = dirname(__FILE__);
require_once $dir . '/PHPRtfLite/PHPRtfLite.php';
ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries/PHPRtfLite/');
if ($rtf)
{
require_once (string) $rtf . EXT;
log_message('debug', "PHPRtfLite Class $rtf Loaded");
}
else
{
log_message('debug', "PHPRtfLite Class Initialized");
}
}
/**
* PHPRtfLite Class Loader
*
* @param string $class class name
*/
function load($rtf)
{
require_once (string) $rtf . EXT;
log_message('debug', "PHPRtfLite Class $rtf Loaded");
}
}
?>
and in the controller the code below was used to test that it was working
Code:
public function testrtf()
{
$this->load->library('PHPRtfLite/PHPRtfLite');
PHPRtfLite::registerAutoloader();
$rtf = new PHPRtfLite();
$sect = $rtf->addSection();
$sect->writeText('<i>hello<b>world</b></i>.', new PHPRtfLite_Font(12), new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER));
// save rtf document
$rtf->save('hello.rtf');
echo 'create ok,and download <a href="'.base_url().'hello.rtf">here</a>';
}