PDFLib throws exception...why?

I have this code which is supposed to create a pdf. but it throws an exception instead:
PDFlibException: Function must not be called in 'object' scope in C:\xampp\htdocs\xampp\sys\pages\pdfinvoice.php on line 306
Call Stack
#      Time      Memory      Function      Location
1      0.0016      147200      {main}( )      ..\pdfinvoice.php:0
2      0.0046      376032      pdfInvoice->__construct( )      ..\pdfinvoice.php:315
3      0.0826      5794384      pdfInvoice->buildReport( )      ..\pdfinvoice.php:44
4      0.1044      5914496      pdfInvoice->createPdf( )      ..\pdfinvoice.php:289
5      0.1047      5972672      PDFlib->begin_page_ext( )      ..\pdfinvoice.php:306

My setup:
In Windows XP Pro....
Downloaded Windows PDFlib-7.0.4p2-MSWin32-php

Copied PDFlib-7.0.4p2-MSWin32-php\bind\php5\php-520\libpdf_php.dll to C:\xampp\php\ext

In C:\xampp\apache\bin\php.ini:
Commented out ;extension=php_pdf.dll

Added in extension=libpdf_php.dll

Everyone seems to have a different opinion about the fix for this...I have already tried every solution posted on google in the first page, including using the default extension in php.ini which just creates a white screen...which is a sure sign of a memory problem and I'm certain this is not the issue...

private function createPdf($sponsor_code, $report)
{
	// Initialize the pdf
	$pdf = new PDFlib();
	$pdf->set_parameter('errorpolicy', 'return');
	$pdf->set_parameter('SearchPath', $this->getConfig('base_dir') . $this->getConfig('page_dir'));
 
	$pdf->set_info('Author', 'RevShare');
	$pdf->set_info('Title', 'RevShare Invoice');
 
	// Start new page: width, height
	$pdf->begin_page_ext(595, 842, 'topdown');
 
	// Name the output file
	$pdf->begin_document("{$sponsor_code}.pdf", "");
	$this->dump($pdf);exit;
}

Open in new window

LVL 3
rae_raeAsked:
Who is Participating?
 
rae_raeConnect With a Mentor Author Commented:
I figured it out :)
0
 
rae_raeAuthor Commented:
Oh, the line failing is: $pdf->begin_page_ext(595, 842, 'topdown');
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.