Hi I have a security model up and running that redirects all requests for files in a secure folder using htaccess to a php page "auth.php" which allows validated users to access to the file using the "readfile_chunked" function below.
The problem is that some, not all, PDF files created using Adobe Pro fail to display at all in browsers - the error is "File does not begin with %PDF-". The file downloads, but does not display with the plugin.
I've tracked it down to what appears to be the metadata and version of adobe, as well as whether the file was 'distilled'.
If there is metadata the file causes the problem above - i think.
For instance, if i "examine a document" in Adobe 9, remove all the metadata and "sensitive information", and save the file as compatible with Adobe 7, it appears to work.
On some files, it doesn't.
I need to read PDFs through PHP for security reasons - in an attempt to avoid header issues, i've left them sparse (there is an IE 6 issue, but that is aside for now since i know it's buggy) - see below for the code.
Is there anyway I can strip a PDF file of its metadata before the readfile_chunked() function? would this prevent the error without having to go through every PDF and recreate it / strip the metadata?
Would something in PDFLib work? I don't need to create the file, i simply need to display it in a cross-browser, multiplatform web environment with PHP based user authentication....