I'm creating a site with downloadable PDF links in which we add a parameter at the end of the file download URL to tell the browser how to serve up the file:
https://example.com?ref=0&download=y
Using the parameter download=y opens the browser's file download dialog, asking the user to save the file to their desktop so they can open it with their machine's default PDF viewer.
Using download=n will open the browser's built-in PDF viewer, allowing the user to read the PDF without saving it to their machine.
I'm trying to understand which approach is more accessible for mobile / desktop / users with disabilities. Is one approach inherently better than the other from an accessibility perspective?
You could always let the user decide. If your link went directly to a PDF, then the user can change their browser settings to either view the PDF within the browser or to use an external viewer. I much prefer that over the web developer trying to choose for me (no offense). Personally, I like to view the PDF externally in Acrobat because the screen reader handles the PDF pretty well if the PDF is tagged. If you don't have a tagged PDF, then it won't matter how you serve up the file because the visually impaired user will have a tough time reading it.
Letting the user decide is the correct approach. This isn't a setting that you should be attempting to configure for accessibilty purposes.
Having properly tagged PDF documents is vastly more important.
It's also good practice that any HTML links to PDF documents be labeled as such in the anchor text.
e.g. Title of Document (PDF)
Related
I have a website where the users can download & view PDFs in browser. I noticed when running an accessibility report on those pages, they are failing in the following two issues:
Documents must have title element to aid in navigation.
html element must have a lang attribute.
The browser page that the PDF sits on does have a title and lang attribute, I can confirm.
I gather this is related to the actual PDF, so I downloaded it then opened it in Adobe Acrobat Reader. If I then go to File > Properties > Description, I can see the document does have a title field. Equally, if I go to the Advanced tab I can see the language is set to en-GB.
Can anyone advise on why it is therefore failing the accessibility scan on those elements?
These errors concern the PDF viewer integrated in the browser, and there is nothing you can do about that.
Both Firefox and Chrome do not assign a language to the HTML that is loading the viewer in the tab. Firefox does expose the document title in <title>, Chrome does not (the whole <head> is empty).
Practical tips
You can provide hints, but cannot control which software opens the linked PDF on the user’s system.
You should make sure that the link makes clear that the target is a PDF file, so that users can take a choice how to treat the link. They might choose to download it from the context menu and then open it in their desktop application.
Many users prefer to know the file type when opening a file that results in opening a new application to view the file, so it is often regarded as useful to include this additional information. However, this is not required for compliance with this Success Criterion.
It’s also helpful to state whether the linked PDF is accessible or not.
Example: Welcome Book (PDF, not tagged for accessibility)
See also PDF link and accessibility -- download yes or no?
Is there a way to share a complex HTML file with box? Currently when I share an HTML5 file it opens in the embedded viewer and it is not rendered correctly. It would be great if I could share a file that could be responsively rendered on all devices without the need for it to be on a hosting site.
For paid Box.com accounts only, you can use a direct link as outlined here:
https://support.box.com/hc/en-us/articles/200519908-Direct-Linking
Unfortunately, with a complex HTML file as you're describing, it may not render properly anyway depending on the browser/device, since the file is downloaded as an attachment and not viewed in the browser via box.com.
I have never thought about this before, but is there a way to control what happens when a user clicks a link to a PDF file?
My boss would like to offer two links to do the following:
1. View this PDF in the browser
2. Download the PDF
Is there a way to do this ? I don't think about these kinds of things, most modern browsers will open a PDF in the browser. If I want to download it, I right-click download. Any way to force the action ?
Thanks
You can link to an asset, or you can stream the data to the browser. Those are the only two options you have on your end.
If you link to a file: <a href="file.pdf"> whether or not it opens in the browser or not is entirely dependent on the end user's browser and operating system preferences.
You can force the download of a file, however by streaming it to the browser, which will usually trigger the browser's save as dialog.
Your best bet, though, from a user experience perspective, is to simply link to the PDF and let the user know that they are about to click on a PDF link...that way they can decide what they do with it.
How PDFs are displayed are based on the user's browser version and configuration. For example Chrome includes a PDF viewer by default, but the user has the ability to change the behavior of the plug-in ( automatically open PDFs, disable, ask the user).
One way to do this is to set the ContentType and Content-Disposition so the browser will know how to handle the request. For example in ASP.NET you would do it like this:
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=filename.pdf");
Disclosure: I hijacked this code from this article
Let me know if this helps.
There are a few ways using server side technologies:
you can link to a .net / php page that serves the file to download, eg:
download pdf
or to display:
view pdf
If you are using itextsharp to generate your pdf, you can add the following to the Response object to force a download:
Response.AddHeader(
"Content-Disposition",
"attachment; filename=itext.pdf"
);
or the following to open in the same window:
Response.AddHeader(
"Content-disposition",
"inline; filename=itext.pdf");
The user can always set their adobe reader plugin to always download, in which case the browser window display won't work.
We need to set up a page to make some highly confidential documents (PDF, Excel, Word) available for viewing only.
The page/documents needs to be as secure as possible (no save, no print etc). We recon that we can't stop print-screen, but hopefully we can limit most of the other options.
How do you best do this? I have currently only two options that I am considering:
Open the documents inside an IFrame and experiment with javascript and css
Create a viewer in Silverlight (or Flash)
If any of you have some ideas on how to achieve this, please tell me. It will be much appreciated!
Word and Excel don't offer a lot of security. I would convert everything you want secured into a PDF and use something like the PDF viewer referenced in this question: Flash document viewer. It's an open source plugin that will allow you to disable save and print and should go a long way towards deterring users from attempting to copy the documents.
I have made an html form. What i want to happen is when the user clicks submit for the page to be emailed as a pdf (like the pdf that comes up if you print the webpage). I've been looking a all sorts of script but nothing seems to do what I want.
You will have to have a server-side component that takes the values, creates the PDF, and then e-mails it appropriately.
You'll be surprised to hear that not all browsers can easily make pdfs out of web pages. Hence, there is no universal JavaScript command that simply taps into a browser's capabilities. That leaves you with options:
Generate the pdf on the server (using, say, pdfbox, and send the email right from the server (using good old sendmail).
Generate the pdf on the server, have the user download it, and then transfer it all to his email client. (Might just work, see on Stackoverflow).
Generate the PDF in the browser, cross-platform. There are some Javascript-only libraries that can generate PDF.
Use Safari's PDF capabilities. Safari can make PDFs just in the print dialog. Explain that to your users and call window.print().