php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mike at phpeeb dot com
New email:
PHP Version: OS:

 

 [2005-03-16 23:02 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-16 23:04 UTC] mike at phpeeb dot com
I got the PDFlib 6 extension from the pdflib.com website.
 [2005-03-17 08:25 UTC] derick@php.net
That's a third party external extensions, please submit all problems to them. Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC