0

I want to print directly a pdf from a url.

I tried window.open(url) but it suggest me to save it. (Because of the .pdf) I just want to print the url directly

Any ideas or suggestions?

Thanks

Toto
  • 49
  • 1
  • 6
  • You would need to open the file first, by open I mean that you either open it in a new tab, or use a iframe. With a iframe you could style it so it wouldn't be visible. This way you could hide that the file has been opened and then you could invoke print in the iframe. – Martin M Jul 26 '18 at 11:47
  • 3
    Possible duplicate of [How to send a pdf file directly to the printer using JavaScript?](https://stackoverflow.com/questions/7074070/how-to-send-a-pdf-file-directly-to-the-printer-using-javascript) – Heretic Monkey Jul 26 '18 at 11:47

2 Answers2

2

To display the file in the same tab of the browser you can use:

window.open(url, "_self");

Or also you can try:

window.location.assign(url);

If by printing you mean in a printer you can use http://printjs.crabbly.com/

TheTanic
  • 1,510
  • 15
  • 29
Maurici Abad
  • 1,012
  • 9
  • 20
2

You have to open the file first in new tab and from there you can download or you can show in same page and from there also you can download

<html>
<head>
</head>
<body>
    <div class="row">

            <div class="col-lg-12">
                <div id="pdfdiv">
                 <a class="media" href="./yourPdfFIleLocation.pdf">Click Me</a>
                </div>
            </div>
        </div>  
</body>