PDFlib not working with explorer based on PHP created file in memory

From: Larry Brown (larry.brown_at_dimensionnetworks.com)
Date: 10/29/03


To: "PHP List" <php-general@lists.php.net>
Date: Wed, 29 Oct 2003 15:39:19 -0500

If anyone can help, please...

I have a page that points to a PHP page that dynamically creates a pdf file
using PDFlib. The page uses a link such as
site.com/page.php?variable=value. That in turn executes the script that
uses the variable/value to pull info from the db and generate the page. The
result is that when you click the link you are prompted to save or open the
document. By openning the document you are presented with the pdf by
acrobat. This is seemless with Mozilla. However, on IE it hangs with the
message "Getting File information:". If you try to save it you get another
error. I have read some information indicating that the problem is with the
length parameter not being sent. However, the page I'm using was off an
example someone provided and it already has what seems to be the fix for
page length. The code that creates the file is as follows...

$p = PDF_new();
if(PDF_open_file($p, "") == 0) {
        die("Error: ".PDF_get_errmsg($p));
}

...body goes here...

PDF_end_page($p);
PDF_close($p);

$buf = PDF_get_buffer($p);
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=filename.pdf");
print $buf;

PDF_delete($p);

Again, this is only a problem with m$ IE. I know this is one of the largest
toolkits (PDFlib) in use for creating well defined printable documents so I
can't believe that this is not a common problem or that I am doing something
really wrong.

Someone on PDFlib's mailing list once mentioned sending the document for
download via "chunks" instead of getting the length except he wrote
something in C/C++ to accomplish it in his app. Is there some way to tell
the browser to accept via "chunks" in php? Does the above header look right
for IE?

Any help would be greatly appreciated...



Relevant Pages

  • RE: [PHP] PDFlib not working with explorer based on PHP created file in memory
    ... archives that had the correct code to use. ... [PHP] PDFlib not working with explorer based on PHP created ... download via "chunks" instead of getting the length except he wrote ...
    (php.general)
  • Re: Parsing data from a string into an array for each match
    ... William Holroyd a écrit le 07/05/2004: ... if you know how to be able to READ a PDF file in PHP let me know. ... An extension to the PDFLib: ...
    (comp.lang.php)
  • Re: [PHP] Simple PDF manipulation
    ... If I recall, we had issues trying to do this with fpdf and some other PHP PDF libraries, but PDFlib allowed us to do it and it's what we've used ever since. ... I found that the insides of a PDF file are not ...
    (php.general)
  • Re: File with no link
    ... You do this in a .php file which as far as the user is concerned ... at the script I suggested. ... When User1 clicks on the link, it opens up ... So, if User1 knows about User2, he can see User2's pdf file. ...
    (comp.lang.php)
  • Re: prevent the direct link with .httaccess file
    ... i have web site that runs on Apache server with php scripts. ... this .htaccess file in pdfs folder but it allow user to read the file.. ... download the pdf file ... He can get much better help with Apache commands from an apache ...
    (comp.lang.php)