Question: In a Web application, is it possible to force a PDF file to be printed on the client? If the browser is configured to open the PDF inside the window, I guess that calling window.print() will work, but some browsers (like mine) are configured to open the PDF externally.

Answer: 
you can use the simple amazing library **printjs** "<http://printjs.crabbly.com>"
it takes PDF file and print it without showing print dialog if you need ,
a simple way to do it below :

```html
 <button type="button" onclick="printJS('docs/printjs.pdf')">
    Print PDF
 </button>
```
If you want to print a PDF via the browser's print dialog, you can render the PDF inside an iframe on which you call the `print()` method.

```
// create iframe element
const iframe = document.createElement('iframe');

// create object URL for your blob or file and set it as the iframe's src
iframe.src = window.URL.createObjectURL(fileOrBlob);
iframe.name = 'pdf';

// call the print method in the iframe onload handler
iframe.onload = () => {
    const pdfFrame = window.frames["pdf"];
    pdfFrame.focus();
    pdfFrame.print();
}
document.body.appendChild(iframe);

```

You can also set `iframe.hidden = true;` to do all of this in a hidden iframe, which the user won't notice.

This solution should work with all major browser's except Legacy Microsoft Edge. If you need to be compatible with Legacy Microsoft Edge you can fall back to the npm package print-js: <https://www.npmjs.com/package/print-js>.