• PHP Help PHP Coding
  • testing php_pdf.dll : function 'PDF_set_info' must not be called in 'object' scope

Hi,
I was testing with the php_pdf.dll with the following code:

$pdf = pdf_new();
pdf_open_file($pdf, "test.pdf");
pdf_set_info($pdf, "Author", "Uwe Steinmann");
pdf_set_info($pdf, "Title", "Test for PHP wrapper of PDFlib 2.0");
pdf_set_info($pdf, "Creator", "See Author");
pdf_set_info($pdf, "Subject", "Testing");
pdf_begin_page($pdf, 595, 842);
pdf_add_outline($pdf, "Page 1");
$font = pdf_findfont($pdf, "Times New Roman", "winansi", 1);
pdf_setfont($pdf, $font, 10);
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);

However, I receive the following error:
Fatal error: PDFlib error: function 'PDF_set_info' must not be called in 'object' scope...

I have check my directory permission. Have already set write permission.

Did I miss out anything? I'm using PHP431 with IIS.

    try to call this function before pdf_open_file function call.

    Z.

      Hi,
      have tried that. But the error still appear.

        4 years later

        Maybe you have the .pdf file open with Acrobat Reader? I had this same problem like 2 minutes ago, then I realized the file was open, and closing it resolved my problems 😃

          Can you do a phpinfo() and verify which version of PHP you're using?

          Also, is error_reporting set to E_ALL ?

            a year later
            shelbytll;10474908 wrote:

            Hi,
            I was testing with the php_pdf.dll with the following code:

            $pdf = pdf_new();
            pdf_open_file($pdf, "test.pdf");
            pdf_set_info($pdf, "Author", "Uwe Steinmann");
            pdf_set_info($pdf, "Title", "Test for PHP wrapper of PDFlib 2.0");
            pdf_set_info($pdf, "Creator", "See Author");
            pdf_set_info($pdf, "Subject", "Testing");
            pdf_begin_page($pdf, 595, 842);
            pdf_add_outline($pdf, "Page 1");
            $font = pdf_findfont($pdf, "Times New Roman", "winansi", 1);
            pdf_setfont($pdf, $font, 10);
            pdf_set_value($pdf, "textrendering", 1);
            pdf_show_xy($pdf, "Times Roman outlined", 50, 750);
            pdf_moveto($pdf, 50, 740);
            pdf_lineto($pdf, 330, 740);
            pdf_stroke($pdf);
            pdf_end_page($pdf);
            pdf_close($pdf);
            pdf_delete($pdf);

            However, I receive the following error:
            Fatal error: PDFlib error: function 'PDF_set_info' must not be called in 'object' scope...

            I have check my directory permission. Have already set write permission.

            Did I miss out anything? I'm using PHP431 with IIS.

            I ran this code without the pdf_add_outline($pdf, "Page 1"); and got a blank page with no error messages.

              Write a Reply...