I am using Drupal version 7.18 and have installed TCPDF package in my library under /var/www/html/drupal-sites/all/libraries
Everything is working well for my generated pdf report.
However, when i open /var/log/php.log on my server, i found errors which was generated everytime i click to generate the PDF report on my site:
PHP Fatal error: Cannot use object of type REPORT_PDF as array in /var/www/html/drupal-7.18/includes/form.inc on line 799
I am not sure what is happening. It has flooded my log file.
REPORT_PDF was an object in the function:
$pdf = new REPORT_PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
NEW INFO AFTER CHANGING hook_menu()
TO REMOVE drupal_get_form()
:
PHP Fatal error: Cannot use object of type REPORT_PDF as array in /var/www/html/drupal-7.18/modules/block/block.module on line 269
I am not sure what is happening. It has flooded my log file.
In my .module file:
$items['report/download/nih_pdf/%'] = array(
'title' => NIH PDF',
'page callback' => 'nih_pdf',
'page arguments' => array(3),
'file' => 'staffreport_pdf.inc',
'access callback' => 'nih_login_access',
);
and in my .inc file:
function nih_pdf($arg1) {
if (!class_exists('TCPDF')) {
include_once(libraries_get_path('tcpdf') . '/tcpdf.php');
}
$pdf = new REPORT_PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('FP System');
$pdf->SetTitle('NIH Report');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array('freesans', '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array('freesans', '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('freesans', '', 10);
$pdf->AddPage();
$pdf->setPrintHeader(false);
$txt = <<
//HTML data displayed as string
EOD;
$pdf->writeHTML($txt, true, false, false, false, '');
ob_end_clean();
//Close and output PDF document
$pdf->Output($staff_num.'_NIH.pdf', 'D');
$pdf->Close();
return $pdf;
}
class REPORT_PDF extends TCPDF {
//Page header
public function Header() {
$this->SetY(15); //use in place of logo
$this->SetFont('freesans', 'B', 16);
$this->Cell(0, 15, 'NIH REPORT', 0, false, 'C', 0, '', 0, false, 'M', 'M');
}
// Page footer
public function Footer() {
$this->SetY(-15);
$this->SetFont('freesans', 'I', 8);
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().' of '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
Hope somebody can assist. Thanks!