I have made a site that archives 147 issues of a community newspaper from the 1970s and 80s. The PDFs of each issue are added via the Resource link. There is a choice of the PDF opening in a browser or being downloaded to the user’s Downloads folder. To search the PDF the user has to open it in their PDF viewer either by clicking the loupe link in the browser or by finding and clicking it in the downloads folder if that option is chosen. I am wondering if it is possible save a step and make the PDF automatically download and open in the user’s default PDF viewer on clicking my site link?
I don’t think that’s possible. There’s an option in Safari Settings that says open “safe” files after downloading, and this might allow PDFs to be opened automatically (I haven’t tested, and I keep the option turned off by default). I think there are similar options in other browsers. So it looks like this is something that is under user control, probably for security reasons.
Do all browsers have an “Open in viewer” icon? I don’t see one in Firefox, but searching within Firefox seems to work OK.
I’m not sure about Safari’s ability to display PDFs correctly. I’ve found that it sometimes fails to display pages (in this example, right-hand pages are missing), so I always open from Safari in a viewer (Preview).
There are ways to force a file that a browser might otherwise take into its own hands (display inline, in the case of a PDF) to download instead, and depending on how the individual user’s browser was configured, that act might cause the file to open in whatever application was configured to be the default app for that file type (Preview.app, Acrobat or Acrobat Reader…). But that’s really quite a shaky proposition.
On a Web server, you can configure the hosting application to send a particular header along with PDF files (or a single file, if you don’t want to make this rule universal). That header is known as content-disposition. If you set it to ‘attachment’ rather than ‘inline’ (the default), then the browser will treat it as something it doesn’t know how to handle itself, and will just download the file as if it was some random non-web-content file.
This is very much an exercise for someone who deeply understands the programming and configuration side of Web servers, btw. Not something that you’re going to get working using a shared hosting provider’s control panel without studying a manual. The usual way to override these kinds of settings in a “surgical” manner is with an .htaccess file (for Apache httpd servers), or the local equivalent.
If you want to force (or at least hint) that a file should be downloaded instead of displayed, there’s a download attribute that can be set on links. Xway displays a Download checkbox for Resource links.
Thank you Jeremy and Walter for your thoughts and background to the problem.
I could not find a search option within the DuckDuck Go browser I was using. The main thing I wanted was for the user to be able to search the PDF without having to download it, go to the download folder and open it in a PDF viewer app. Your mention, Jeremy, about no ‘open in viewer’ icon in Firefox got me thinking and I looked at my PDFs in four Mac browsers. I was surprised to find the range of solutions built-in for viewing PDFs from fully featured viewers (Chrome) to very basic, but what was common among them was that all you need to do to start a search in any browser (on my laptop) was to hit Cmd-F. I had to link my iPhone to an Acrobat account to get the same easy access on my mobile, but once done that works seamlessly too.
Just need a simple site search now to find topics across all 174 PDFs. That will be solved when the site is eventually merged into a database driven solution, but for now I am happy that is easy to search individual issues within any browser on my Xway site.
Safari, and probably most or all other browsers on iOS, can also search PDFs with the inline viewer. The search is just not very obvious to access.
Once the page/PDF/whatever you want to search is loaded in the browser, tap the address bar and start typing. On the screen you’ll see how many matches there are and Find “whatever you typed”, tap that and it’ll open the search interface.