PDFLib throws exception...why?

Posted on 2009-04-22
Last Modified: 2012-05-06
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

Question by:rae_rae
    LVL 3

    Author Comment

    Oh, the line failing is: $pdf->begin_page_ext(595, 842, 'topdown');
    LVL 3

    Accepted Solution

    I figured it out :)

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now