File link to view / download / print

1

Scenario

I have a list of files dynamically generated, and I would like 3 options:

  • Open : display in the browser (if it is PDF, JPG, etc);
  • Download : download direct;
  • Print : Send direct to standard printer .

What I got

View with target="_blank in tag <a> :

<td><a href="files/100-1533649017.pdf" target="_blank">MeuArquivo.pdf</a></td>

Download with download in tag <a> :

<td><a href="files/100-1533649017.pdf" download>MeuArquivo.pdf</a></td>

Questions

  • Immediately, I could not find to send the printer directly , is there a native HTML form for this?
  • If there is no native HTML form, what alternatives?
  • Is there another way , which I used to view ?
  • Is there another way to use download ?
asked by anonymous 21.08.2018 / 14:06

2 answers

0

To open direct, simply create a link <a href="/path/arquivo.pdf">Abrir</a>

To print, use window.print(); , there is no way to send it directly to the printer.

In the case of a download, it is possible, as long as the file is the same source as your server, since the browsers themselves block the download tag for security reasons if the links come from another url

21.08.2018 / 15:59
0

You can not send a file to print, but what you can do is display the contents of this file on a screen and execute the javascript command for print as mentioned above. After this command close this screen with window.close. It is "almost" the same thing. It may be possible to do this within an invisible iframe.

    
01.11.2018 / 05:37