• Hello,

    When your website offers direct links to PDF files (I’m working on my wife’s ebooks website, she wants to offer two links, to view, or to download), I’ve seen various ways to force these PDF files to be always downloaded instead of viewed online.

    However, is there a way to differentiate links to PDF files, so that they may either be downloaded, OR opened inside the browser ?

    Inside WordPress, I really don’t see how that could be done, and yet, I spent a long time searching the internet…

    Thank you VERY MUCH if you can help me with a suggestion, a link, or a trick ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • I think it is a browser issue. FF4 auto opens this, https://www.fema.gov/pdf/areyouready/areyouready_full.pdf

    while IE8 asks me if I want to open or save.

    Thread Starter sabinou

    (@sabinou)

    Well, this is partly a browser issue, but not always.

    Allow me to clarify what I mean : not all browsers share the same settings.
    – if the browser’s rule is to ALWAYS give choice between viewing and downloading, then my job is done, there is nothing I can do for my wife’s ebooks website
    – if the browser’s rule is to ALWAYS open the pdf online unless it’s php-hardcoded to force the download or wordpress forces this mimetype to downloading only, then the PDF will be open online by default.
    To this day, except IE, I think that all other modern browsers open the PDFs online by default.

    And it’s in this second situation that I can help my wife if I find how to force WordPress to handle differently two links to a PDF, one way or another.

    PDf documents are great for online viewing. Since they are cross-platform and preserve the information and appearance of the source file, PDFs are commonly used to present information on the Internet. However, the ability to view a PDF document online does depend on the user having a PDF viewer on his computer.

    That is why so many pdf documents have as link next to them to download the reader. Even with FF the Adobe reader is a plugin. I think it comes with FF by default but it can be disabled like all FF’s plugins.

    Most likely I don’t have IE’s reader turned on as I am still trying to figure IE9 and Windows 7 out. Note to ones self: don’t upgrade two important tools at the same time . . .

    Thread Starter sabinou

    (@sabinou)

    Thank you for your time, I’m grateful, really – however, you’re dead wrong, your advice is almost the exact opposite of whant I want.

    By default, on most browsers, PDFs are viewed online if you click the link to them.

    In wordpress too.
    Except if we hard-code into wordpress the fact that a pdf isn’t a file to view online, but instead, a file that MUST be downloaded to disk.

    Me, I want a midway solution.
    Something to make the link we create either point to the usual “do whatever you want with it, Browser” version, or to the “you can ONLY download it, no choice, Browser !” version.

    By default, on most browsers, PDFs are viewed online if you click the link to them.

    I agree with that but Chrome, FF and IE use plugins which can be disabled. Not that I can think of a reason to do so.

    I have seen some just say, “To download, right click.” Though I understand you are looking for a more elegant solution. Have you looked at Adobe for any information?

    however, you’re dead wrong

    You may think so but in doing so, you’re also . . . incorrect.

    Hi there,
    I know what you need, sabinou, as I am having the same issue.

    My website has several PDFs (restaurant menus).

    UNTIL I updated FIREFOX TO 4.0.1, the PDFs opened onto a webpage, where the user could look at the menu and then choose to download if he wished.

    Now that I switched servers (away from the awful GoDaddy) to HostGator (very good customer service) and updated FF, my PDFs NOW just open a window asking if I want to Save or Download, etc.

    There must be a way in WordPress (when you are creating the link for the PDF?) where you can set HOW you want the PDF to display.

    have you found a solution, sabinou?? If so please do let me know!

    thanks

    It’s a browser issue. There’s is nothing to you can do about it within WordPress. End of.

    Sorry.

    Hey!

    2 ways to solve your problem – if you haven’t figured it out yet ??

    1. .htaccess file
    browser will likely open this file directly:
    AddType application/pdf
    and files described as this, browser most likely will DL and save:
    AddType application/octet-stream .pdf

    2. php function which will set required headers b4 sending file to client, something like this..

    <?php
    header('Content-Disposition: attachment; filename=' . urlencode($f));
    header('Content-Type: application/force-download');
    header('Content-Type: application/octet-stream');
    header('Content-Type: application/download');
    header('Content-Description: File Transfer');
    header('Content-Length: ' . filesize($f));
    echo file_get_contents($f);
    ?>

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Two kinds of links for pdf, view online OR download’ is closed to new replies.