1

I have recently created a simple website for a friends new restaurant. I have included a button which prompts a download of the restaurants menu in .pdf format.

This download works fine when tested on a laptop/desktop (windows), the menu is downloaded and can be opened with no problems. It also works on iPad, the menu opens up right away and can be viewed without problems.

The problem comes on mobile (Android). When you click the button the menu looks as though it is going to open but every time it fails and says:

Error: menuname.pdf cannot be opened as it is of wrong format.

I have tested it on a few different phone brands (LG, Sony) and get the same problem on each. I have looked around for an answer but there isn't much to go on.

Is there a different approach that needs to be considered for opening it on mobile? (As it works perfectly on laptop etc)

I have just used HTML to implement the download feature by adding the 'Download' element to the button / link.

<a href="resources/files/menuname.pdf" class="btn btn-empty" title="menuname" download="menuname.pdf" target="_blank">Download menu</a>

Any help would be greatly appreciated.

Wes Foster
  • 8,770
  • 5
  • 42
  • 62
Skirky
  • 21
  • 3
  • 1
    Why did you remove the most helpful part of your question? (the link example) – J. Titus Mar 14 '16 at 12:17
  • I haven't posted a question on SO before and it seemed like the code wasn't appearing in the post? – Skirky Mar 14 '16 at 12:22
  • At first the code was not visible in the post. I edited it so that the code was visible and more helpful to people looking at the question trying to answer it. Then you removed it. I'm guessing you just missed seeing that it had been edited to show the code. – J. Titus Mar 14 '16 at 12:25
  • Ah, apologies I must have missed it. I have re-added the code example now. Thanks! – Skirky Mar 14 '16 at 12:30
  • There's a chance that the PDF is invalid. Check its mime type. On linux, it can be done with `file` http://stackoverflow.com/a/2227201/1207687 -- Bottom line, you need to ensure that the file is a valid PDF. – Wes Foster Mar 14 '16 at 12:48
  • Still haven't managed to get this working on all devices for whatever reason. As far as I know it works on most things except Android. I have tested on Laptop/Desktop (Windows), iPad and iPhone which are all working fine. All 3 Android devices I have tried have all had the same error (name.pdf cannot be opened as it is of the wrong format). I will keep testing various things and give an update if I find the cause of the problem. Thanks for the help so far! – Skirky Mar 21 '16 at 15:32

0 Answers0