printJS - why requested URL not found error when printing PDF file?

1.6k views Asked by At

trying to use printJS to print a PDF file, from the browser, direct to a network printer. But getting error: "The requested URL /docs/pricelist.pdf was not found on this server"

but the file is there. I am able to use an anchor link to download it.

and, I am loading printJS correctly since I can use it to print an HTML element.

how to correctly use printJS to print a PDF from the browser?

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">

  <link rel="stylesheet" 
      href="https://printjs-4de6.kxcdn.com/print.min.css">
  <script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>

  <title>Document</title>
</head>
<body id="body" >

  <a href="docs/pricelist.pdf">pricelist pdf</a>

  <button type="button" onclick="printJS('docs/pricelist.pdf')">
    Print PDF
  </button>

<button type="button" onclick="printJS('body', 'html')">
  Print HTML
</button>

</body>
</html>
1

There are 1 answers

0
Usira On BEST ANSWER

Try with complete url.

Example -: http://www.exampl.lk/ebook/s12syl18.pdf