|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32344 pdf_open_file() expects exactly 2 parameters, among others
Submitted: 2005-03-16 23:02 UTC Modified: 2005-03-17 08:25 UTC
From: mike at phpeeb dot com Assigned:
Status: Not a bug Package: PDF related
PHP Version: 4.3.9 OS: Windows XP Pro (SP1)
Private report: No CVE-ID: None
 [2005-03-16 23:02 UTC] mike at phpeeb dot com
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");

// 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);


Expected result:
A PDF file that simply reads "Testing PDF Document Creation".

Actual result:
Blank page or corrupt PDF depending on content disposition


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-16 23:04 UTC] mike at phpeeb dot com
I got the PDFlib 6 extension from the website.
 [2005-03-17 08:25 UTC]
That's a third party external extensions, please submit all problems to them. Thank you.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat May 25 21:01:27 2019 UTC