Making pdfs prompt customer for download?

11 replies
Hey guys, I was setting up something when I ran into a small issue.

Basically, I've got a pdf and I want it to prompt the customer for download so they'll have it on their computer, but instead when I click the link, it just opens up with my browser.

I don't know if there is a special html code for this or if it's just browser settings, but either way, I'd appreciate the help. Thanks everyone!
#customer #download #making #pdfs #prompt
  • Profile picture of the author webapex
    Right mouse click, save file as.

    Wording varies among browsers.
    Signature

    “An expert is a person who has made all the mistakes that can be made in a very narrow field” Niels Bohr

    {{ DiscussionBoard.errors[4840726].message }}
  • Profile picture of the author mattmax
    You need to look up "content disposition" for whatever scripting language your site runs on.

    Assuming it is PHP, you would basically create an intermediate file (php) that would set the proper headers, and then read the file you are sending to the user.
    {{ DiscussionBoard.errors[4840731].message }}
  • Profile picture of the author WillR
    Yes, you can add content disposition headers to the file but an easier way to achieve this is to put the file into a folder and zip the folder. That way they are downloading a .zip file not a .pdf file and won't be able to view it in their browser - it will force the download.
    {{ DiscussionBoard.errors[4840772].message }}
    • Profile picture of the author mattmax
      Originally Posted by WillR View Post

      Yes, you can add content disposition headers to the file but an easier way to achieve this is to put the file into a folder and zip the folder. That way they are downloading a .zip file not a .pdf file and won't be able to view it in their browser - it will force the download.
      I'll second this - zipping the file is the easiest way to accomplish the end goal with minimum hassle. If you absolutely have to have them download a PDF, though, then the content disposition is the way to go.
      {{ DiscussionBoard.errors[4840784].message }}
    • Profile picture of the author ShiningHero
      Originally Posted by WillR View Post

      Yes, you can add content disposition headers to the file but an easier way to achieve this is to put the file into a folder and zip the folder. That way they are downloading a .zip file not a .pdf file and won't be able to view it in their browser - it will force the download.
      Thanks Will, seems like whenever I ask a question, you're posting answering it LOL, thanks!

      Second (this question @ everyone) I'm using open office to make my PDFs, and even when I set the hyperlink to a "blank" frame, if the viewer is reading my pdf in their browser, the link does not open in a new tab. Does anyone know how to make PDFs hyperlink open in a new tab if the viewer does happen to read in their browser? I hate that it takes them off the pdf page!
      {{ DiscussionBoard.errors[4845440].message }}
      • Profile picture of the author Thomas
        Originally Posted by warhero View Post

        Second (this question @ everyone) I'm using open office to make my PDFs, and even when I set the hyperlink to a "blank" frame, if the viewer is reading my pdf in their browser, the link does not open in a new tab. Does anyone know how to make PDFs hyperlink open in a new tab if the viewer does happen to read in their browser? I hate that it takes them off the pdf page!
        That's a very good question: I just tried it in Firefox using the blank, self, parent, and top target attributes, and they ALL opened in the same window as the PDF. Maybe it can't be done.
        {{ DiscussionBoard.errors[4846503].message }}
      • Profile picture of the author WillR
        Originally Posted by warhero View Post

        Thanks Will, seems like whenever I ask a question, you're posting answering it LOL, thanks!

        Second (this question @ everyone) I'm using open office to make my PDFs, and even when I set the hyperlink to a "blank" frame, if the viewer is reading my pdf in their browser, the link does not open in a new tab. Does anyone know how to make PDFs hyperlink open in a new tab if the viewer does happen to read in their browser? I hate that it takes them off the pdf page!
        I'm not sure this can be done, maybe someone has a solution. I have always hated that as well when viewing a pdf in the browser and you click on a link and get thrown away from the PDF. That's why your idea to force people to download the PDF document is much better. It also means they will have a copy of the PDF on their desktop until they delete it - which makes them that much more likely to read it than those who just view it in a browser.
        {{ DiscussionBoard.errors[4847593].message }}
      • Profile picture of the author mattmax
        Originally Posted by warhero View Post

        Thanks Will, seems like whenever I ask a question, you're posting answering it LOL, thanks!

        Second (this question @ everyone) I'm using open office to make my PDFs, and even when I set the hyperlink to a "blank" frame, if the viewer is reading my pdf in their browser, the link does not open in a new tab. Does anyone know how to make PDFs hyperlink open in a new tab if the viewer does happen to read in their browser? I hate that it takes them off the pdf page!
        This might be able to be done using JavaScript in the PDF (as opposed to a regular hyperlink).
        {{ DiscussionBoard.errors[4849346].message }}
  • Profile picture of the author samstephens
    Zipping does make it quite easy!

    Or if you want to keep the file in PDF format, have you considered using a download/sales management script?

    DLGuard is one I created and is quite popular on the Warrior forum - it'll force downloads of PDF files for you, as well as giving you a secure download link (and well as customer management, sales security, etc.)

    Let me know if you'd like me to clarify!

    cheers
    Sam
    Signature
    DLGuard v5 - The Warrior Edition
    Full integration with JVZoo, DigiResults, and WSO Pro for secure WSO's and WSO memberships.

    www.dlguard.com
    Serving the Warrior Forum since 2004
    {{ DiscussionBoard.errors[4841098].message }}
    • Profile picture of the author JennySweets
      lol the answers to zip the pdf remind me of the thread earlier asking WSO creators NOT to zip a single pdf.

      so maybe throw a readme with something worth 2 seconds to read in the zip too :p
      {{ DiscussionBoard.errors[4841686].message }}
  • Profile picture of the author Thomas
    Originally Posted by warhero View Post

    Basically, I've got a pdf and I want it to prompt the customer for download so they'll have it on their computer, but instead when I click the link, it just opens up with my browser.

    I don't know if there is a special html code for this or if it's just browser settings, but either way, I'd appreciate the help. Thanks everyone!
    Try this:

    How to Force a PDF to Download using Apache

    (Although you'll have to know how to access your htaccess file to use it.)

    Tommy.
    {{ DiscussionBoard.errors[4846455].message }}

Trending Topics