WordPress.org

Support

Support » Miscellaneous » Force download of pdf

Force download of pdf

  • danfloun

    @danfloun

    Hey,

    How can I force the download of pdf files instead of them opening in the browser via Adobe pdf plugin.

    I know you can do this through php but is there something that will do this without editing code?

    Cheers
    Danny

Viewing 3 replies - 1 through 3 (of 3 total)
  • thisisedie

    @thisisedie

    What does this have to do with WordPress?

    danfloun

    @danfloun

    Everything,
    My site sometimes includes links to pdf file of interest but it tries to open them in the browser. I want the user to download them instead.

    Clayton James

    @claytonjames

    This happens because most plugins or handlers installed for .pdf files are set by default to open .pdf’s in a browser window (Adobe reader, for one), then give the viewer the option to save a copy of the document locally. You can compress the .pdf and offer the .zip for download. Zip files usually open a dialog for the user, and asks if they want to open or save the file, as opposed to the pdf plugin that usually just opens the document. I think you could also force the download via javascript, but that will indeed require some code editing, and I question how safe it may be. If your http server is under your complete control, you may be able to force the pdf to download by changing your mime.types configuration.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Force download of pdf’ is closed to new replies.