|
|
| Author |
Message |
RichLorn
 Total Messages 6
|
| Subject: | direct pdf download thru php |
The intention here is to allow the user to download a .pdf directly to their computer (with the appropriate browser popups asking for user permission) without the .pdf first opening in Reader. I'm using the following server-side script, which is from an example shown on W3Schools for http php:
header(Content-disposition: attachment; filename=ezdiary.pdf');
header(Content-type: application/pdf');
readfile(ezdiary.pdf');
?>
(the opening ?php isn't showing up in my message, but its there)
The file downloads, but then when I subsequently try to open it in Reader, the following error appears:
"Adobe Reader could not open 'ezdiary.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)."
The pdf was created in livecycle 8.2, reader rights enabled, and works correctly when loaded into Reader v9 on my local machine. But not after downloading on either IE8 or Firefox 3.6 from my host's apache server.
After downloading, a right-click on pdf properties shows a file size of 238bytes and a file size on disk of 4kb. The original pdf is approx 1900kb compressed. I also tried uploading an uncompressed version of the pdf to my web site (approx 3800kb) but the download still yeilded the same error and file sizes.
Does anyone have some insight why the pdf is not decoding correctly?
Posted: 02 May 2011 08:00 AM Originally Posted: 02 May 2011 07:55 AM |
|
|
| |
aandi
 Total Messages 17064
|
| Subject: | direct pdf download thru php |
Have you taken a look in the not-PDF (e.g. with Notepad)?
| Posted: 02 May 2011 11:44 AM |
|
|
| |
RichLorn
 Total Messages 6
|
| Subject: | direct pdf download thru php |
Hi Aaandi
You lost me. What do you mean by not-pdf in notepad?
| Posted: 02 May 2011 02:27 PM |
|
|
| |
aandi
 Total Messages 17064
|
| Subject: | direct pdf download thru php |
There's a file you expect to be a PDF. Clearly it isn't - it doesn't work, and it's only 238bytes.
What's inside the file?
| Posted: 02 May 2011 02:30 PM |
|
|
| |
RichLorn
 Total Messages 6
|
| Subject: | direct pdf download thru php |
I understood what you meant after I posted.
Warning: readfile(ezdiary.pdf) [function.readfile]: failed to open stream: No such file or directory in /home/content/82/7799482/html/fulfillment/ezdiary.php on line 6
The pdf is located in the same folder as the php
| Posted: 02 May 2011 02:44 PM |
|
|
| |
RichLorn
 Total Messages 6
|
| Subject: | direct pdf download thru php |
I understood what you meant after I posted.
Warning: readfile(ezdiary.pdf) [function.readfile]: failed to open stream: No such file or directory in /home/content/82/7799482/html/fulfillment/ezdiary.php on line 6
The pdf is located in the same folder as the php
| Posted: 02 May 2011 02:51 PM |
|
|
| |
aandi
 Total Messages 17064
|
| Subject: | direct pdf download thru php |
Ok, I don't know anything about PHP but it looks as if this is a PHP diagnostic. I would suspect either that the default directory isn't the same directory as the current one, or that the site admin has set up security so you cannot read files in this way. If you don't get a reply here, you might find the experts you need in a PHP group.
| Posted: 03 May 2011 12:20 AM |
|
|
| |
RichLorn
 Total Messages 6
|
| Subject: | direct pdf download thru php |
Ok Aandi, thanks for trying anyway. :)
| Posted: 03 May 2011 06:53 AM |
|
|
| |
|
|