I am downloading a PDF that was produced offline. When I download it or view it, I get the message: "There was an error opening your document. The file is damaged and could not be repaired." When I tested it locally, It opened without any problem; the problem only happens from the web server.
The odd thing is when I open the file in a text editor, there is additional info that shouldn't be there. The correct header looks like this:
The bad header looks like this:
In addition, my source code for the download page is at the end of the pdf.
I'm not sure that it matters but the file is located outside of the webroot. There are no security issues, so putting it inside is not a problem if anyone thinks that will help. Here is the code that I am using.
I did play around with the mime_type and tried "application/pdf" and got worse results (5k file); I'm not sure that has anything to do with it but I thought I'd throw it out there.
Any insight would be greatly appreciated.
Thanks,
Tom
The odd thing is when I open the file in a text editor, there is additional info that shouldn't be there. The correct header looks like this:
Code:
%PDF-1.4 %���� 215 0 obj <</Linearized 1/L 1458936/O 217/E 707280/N 4/T 1454515/H [ 4116 733]>> endobj xref 215 191 0000000016 00000 n 0000004849 00000 n
Code:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> %PDF-1.4 %���� 215 0 obj <</Linearized 1/L 1458936/O 217/E 707280/N 4/T 1454515/H [ 4116 733]>> endobj xref 215 191 0000000016 00000 n 0000004849 00000 n
I'm not sure that it matters but the file is located outside of the webroot. There are no security issues, so putting it inside is not a problem if anyone thinks that will help. Here is the code that I am using.
Code:
if eval_valid("submit0") response.mime_type = resolve_mime_type("PDF") response.add_header("Content-disposition: attachment; filename=" + urlFile) ?file.to_blob(urlFilepath) end if
Any insight would be greatly appreciated.
Thanks,
Tom
Comment