• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

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", "");

Open in new window

  • 2
1 Solution
rae_raeAuthor Commented:
Oh, the line failing is: $pdf->begin_page_ext(595, 842, 'topdown');
rae_raeAuthor Commented:
I figured it out :)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now