#32344 [Opn]: pdf_open_file() expects exactly 2 parameters, among others
| From: | mike at phpeeb dot com | Date: | Wed, 16 Mar 2005 22:04:08 +0000 |
| Subject: | #32344 [Opn]: pdf_open_file() expects exactly 2 parameters, among others | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-75401@lists.php.net to get a copy of this message | ||
ID: 32344
User updated by: mike at phpeeb dot com
Reported By: mike at phpeeb dot com
Status: Open
Bug Type: PDF related
Operating System: Windows XP Pro (SP1)
PHP Version: 4.3.9
New Comment:
I got the PDFlib 6 extension from the pdflib.com website.
Previous Comments:
------------------------------------------------------------------------
[2005-03-16 23:02:26] mike at phpeeb dot com
Description:
------------
This bug has been mentioned before, but not with my operating system,
as far as I can tell.
The PDF_open_file() function is documented at only requiring the
resource, and not the second argument. Howerver, I get this error:
pdf_open_file() expects exactly 2 parameters, 1 given ....
When I use a second argument, It gives this error:
pdf_get_buffer(): [1052] PDF_get_buffer: Don't fetch buffer contents
when writing to file in...
When the two lines relating to the buffer are commented out, I get no
more errors, yet the output PDF file is corrupt. When using inline
disposition, a blank page is the result, when attachment is used, Adobe
Reader launches, yet it reurns an error saying the document is corrupt.
The code used was from an example, that apparently works for countless
people, so I know it's not the code itself that is bad.
Reproduce code:
---------------
$pdf = pdf_new();
pdf_open_file($pdf, 'e');
pdf_begin_page($pdf, (72 * 8.5), (72 * 11));
$font = pdf_findfont($pdf, "Times-Roman", "host", 0);
// Some code snipped //
pdf_show($pdf, "Testing PDF Document Creation");
pdf_end_page($pdf);
pdf_close($pdf);
// The following line produces error when not commented out //
$length = strlen(pdf_get_buffer($pdf));
header("Content-Type: application/pdf");
header("Content-Length: ".$length);
header("Content-Disposition: attachment; filename=test.pdf);
pdf_delete($pdf);
Expected result:
----------------
A PDF file that simply reads "Testing PDF Document Creation".
Actual result:
--------------
Blank page or corrupt PDF depending on content disposition
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32344&edit=1