#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    39
    Rep Power
    0

    Passing a pdf file through php


    I am used this code:

    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false);
    header("Content-Type: application/pdf");
    header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    readfile("$filename");

    and it does open the file and pass it through the browser, after it downloads, when I open the PDF file, it tells me that it could not open the file because "it is either not a supported file type or because the file has been damaged..."

    can you tell me how to fix this?

    Thank you.
    Richard
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,003
    Rep Power
    376
    there is a library fpdf or something similar (please search). I used it couple of years back and it created PDFs for me.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    39
    Rep Power
    0
    I don't need to create a pdf, just pass it through... open it and print it to their browser, so that they can download it securely.
    That way if they share it, they have to share the file, not the link to download(saving my bandwidth)...

    A few of the files are encrypted as well, allowing the file to open and print in high resolution, but not changable... so it has to be able to still download those. I use a wordpress plugin that secures the link, but with the encrypted files, they are unreadable, so show as damaged when downloaded. So I wrote the php script to download them instead of the securelink plugin.

    Any ideas how to make this work, without having to create a pdf, just pass an existing one through?

    Thank you.
    Richard



    Originally Posted by paulh1983
    there is a library fpdf or something similar (please search). I used it couple of years back and it created PDFs for me.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,003
    Rep Power
    376
    so are you saying the file is already a pdf?

IMN logo majestic logo threadwatch logo seochat tools logo